aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/prepare.c2
-rw-r--r--src/vdbesort.c5
2 files changed, 3 insertions, 4 deletions
diff --git a/src/prepare.c b/src/prepare.c
index acd50fcaf..f8ad54665 100644
--- a/src/prepare.c
+++ b/src/prepare.c
@@ -582,8 +582,8 @@ static int sqlite3Prepare(
zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);
if( zSqlCopy ){
sqlite3RunParser(pParse, zSqlCopy, &zErrMsg);
- sqlite3DbFree(db, zSqlCopy);
pParse->zTail = &zSql[pParse->zTail-zSqlCopy];
+ sqlite3DbFree(db, zSqlCopy);
}else{
pParse->zTail = &zSql[nBytes];
}
diff --git a/src/vdbesort.c b/src/vdbesort.c
index 22029aa6b..380772ee1 100644
--- a/src/vdbesort.c
+++ b/src/vdbesort.c
@@ -1821,6 +1821,7 @@ int sqlite3VdbeSorterWrite(
if( nMin>pSorter->nMemory ){
u8 *aNew;
+ int iListOff = (u8*)pSorter->list.pList - pSorter->list.aMemory;
int nNew = pSorter->nMemory * 2;
while( nNew < nMin ) nNew = nNew*2;
if( nNew > pSorter->mxPmaSize ) nNew = pSorter->mxPmaSize;
@@ -1828,9 +1829,7 @@ int sqlite3VdbeSorterWrite(
aNew = sqlite3Realloc(pSorter->list.aMemory, nNew);
if( !aNew ) return SQLITE_NOMEM;
- pSorter->list.pList = (SorterRecord*)(
- aNew + ((u8*)pSorter->list.pList - pSorter->list.aMemory)
- );
+ pSorter->list.pList = (SorterRecord*)&aNew[iListOff];
pSorter->list.aMemory = aNew;
pSorter->nMemory = nNew;
}