1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Fix problems in the sqlite3expert.c code revealed by -fsanitize.

FossilOrigin-Name: 7a93dd784bfdbf01927979a61643796e0901d9ac285fe4214677838def93a9a4
This commit is contained in:
dan
2018-01-08 17:34:15 +00:00
parent 4064a4cc58
commit d4bb7c180b
3 changed files with 10 additions and 10 deletions

View File

@@ -495,7 +495,7 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){
}
}
pIdxInfo->estimatedCost = 1000000.0 / n;
pIdxInfo->estimatedCost = 1000000.0 / (n+1);
return rc;
}
@@ -754,7 +754,7 @@ static char *idxAppendText(int *pRc, char *zIn, const char *zFmt, ...){
zRet = (char*)sqlite3_malloc(nIn + nAppend + 1);
}
if( zAppend && zRet ){
memcpy(zRet, zIn, nIn);
if( nIn ) memcpy(zRet, zIn, nIn);
memcpy(&zRet[nIn], zAppend, nAppend+1);
}else{
sqlite3_free(zRet);
@@ -908,7 +908,7 @@ static int idxCreateFromCons(
char *zCols = 0;
char *zIdx = 0;
IdxConstraint *pCons;
int h = 0;
unsigned int h = 0;
const char *zFmt;
for(pCons=pEq; pCons; pCons=pCons->pLink){