diff options
author | drh <drh@noemail.net> | 2017-04-17 20:50:34 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-04-17 20:50:34 +0000 |
commit | e2bc6552fe50c6f6cb3189c40e23de329c9c3802 (patch) | |
tree | 599e386fd0c73df746aedd5bd8aaa820b74c5a10 /src | |
parent | 4bee5599c0cce4d3e100ce4e07e8ab09548a9084 (diff) | |
download | sqlite-e2bc6552fe50c6f6cb3189c40e23de329c9c3802.tar.gz sqlite-e2bc6552fe50c6f6cb3189c40e23de329c9c3802.zip |
Do not allow a Mem object to be both NULL and some other type at the same time.
FossilOrigin-Name: e698db1956bb3aba32cd3ec633ec20f5d19b1a10bc68d3772903bca3c87ee158
Diffstat (limited to 'src')
-rw-r--r-- | src/vdbe.c | 3 | ||||
-rw-r--r-- | src/vdbemem.c | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/vdbe.c b/src/vdbe.c index a990afb11..ebd304ecb 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -486,6 +486,7 @@ static void registerTrace(int iReg, Mem *p){ printf("REG[%d] = ", iReg); memTracePrint(p); printf("\n"); + sqlite3VdbeCheckMemInvariants(p); } #endif @@ -1151,7 +1152,7 @@ case OP_Null: { /* out2 */ case OP_SoftNull: { assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) ); pOut = &aMem[pOp->p1]; - pOut->flags = (pOut->flags|MEM_Null)&~MEM_Undefined; + pOut->flags = (pOut->flags&~(MEM_Undefined|MEM_AffMask))|MEM_Null; break; } diff --git a/src/vdbemem.c b/src/vdbemem.c index 4f5789376..e95a8d1b9 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -40,6 +40,10 @@ int sqlite3VdbeCheckMemInvariants(Mem *p){ /* Cannot be both MEM_Int and MEM_Real at the same time */ assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) ); + /* Cannot be both MEM_Null and some other type */ + assert( (p->flags & MEM_Null)==0 || + (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob))==0 ); + /* The szMalloc field holds the correct memory allocation size */ assert( p->szMalloc==0 || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |