Fix a bug in the EXPLAIN code for listing trigger programs that was causing an out-of-bounds read.

FossilOrigin-Name: c9342ca58105499a5eb61c3e6d016559b6072c95
This commit is contained in:
dan
2012-03-31 09:59:44 +00:00
parent 5fb52caadf
commit 2b9ee77fd6
4 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -1239,7 +1239,7 @@ int sqlite3VdbeList(
for(j=0; j<nSub; j++){
if( apSub[j]==pOp->p4.pProgram ) break;
}
if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){
if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){
apSub = (SubProgram **)pSub->z;
apSub[nSub++] = pOp->p4.pProgram;
pSub->flags |= MEM_Blob;
+8 -4
View File
@@ -59,10 +59,10 @@ int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
** Make sure pMem->z points to a writable allocation of at least
** n bytes.
**
** If the memory cell currently contains string or blob data
** and the third argument passed to this function is true, the
** current content of the cell is preserved. Otherwise, it may
** be discarded.
** If the third argument passed to this function is true, then memory
** cell pMem must contain a string or blob. In this case the content is
** preserved. Otherwise, if the third parameter to this function is false,
** any current string or blob value may be discarded.
**
** This function sets the MEM_Dyn flag and clears any xDel callback.
** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
@@ -77,6 +77,10 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve){
);
assert( (pMem->flags&MEM_RowSet)==0 );
/* If the preserve flag is set to true, then the memory cell must already
** contain a valid string or blob value. */
assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
if( n<32 ) n = 32;
if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
if( preserve && pMem->z==pMem->zMalloc ){