diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vdbeaux.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/vdbeaux.c b/src/vdbeaux.c index de7f48212..dbbb2a6cc 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1851,19 +1851,24 @@ void sqlite3VdbeMakeReady( /* zCsr will initially point to nFree bytes of unused space at the ** end of the opcode array, p->aOp. The computation of nFree is ** conservative - it might be smaller than the true number of free - ** bytes, but never larger. nFree might be negative. But the allocation - ** loop will still function correctly. + ** bytes, but never larger. nFree must be a multiple of 8 - it is + ** rounded down if is not. */ - zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */ - nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */ - if( nFree>0 ) memset(zCsr, 0, nFree); + n = ROUND8(sizeof(Op)*p->nOp); /* Bytes of opcode space used */ + zCsr = &((u8*)p->aOp)[n]; /* Unused opcode space */ + assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); + nFree = ROUNDDOWN8(pParse->szOpAlloc - n); /* Bytes of unused space */ + assert( nFree>=0 ); + if( nFree>0 ){ + memset(zCsr, 0, nFree); + assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); + } resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) ); p->expired = 0; /* Memory for registers, parameters, cursor, etc, is allocated in two |