New assert() statements to help ensure that no other errors similar
to [343634942dd54ab57b7] ever appear in the code. FossilOrigin-Name: 5a70af1e9c567f12c997d25d0a305a8d42bf2cc92f2811e9d5fdde720665e213
This commit is contained in:
parent
c3ef23a1c9
commit
563ddbe54d
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\smemory\sleak\sthat\scould\sfollow\san\sIO\serror\sin\sthe\szipfile\sextension.\sAnd\nadd\sother\stests.
|
||||
D 2018-02-01T15:19:54.965
|
||||
C New\sassert()\sstatements\sto\shelp\sensure\sthat\sno\sother\serrors\ssimilar\nto\s[343634942dd54ab57b7]\sever\sappear\sin\sthe\scode.
|
||||
D 2018-02-01T15:57:00.046
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in 7a3f714b4fcf793108042b7b0a5c720b0b310ec84314d61ba7f3f49f27e550ea
|
||||
@ -562,7 +562,7 @@ F src/vdbeInt.h 8d7d07f13cb3c4cbca91e22ba4a1920e542dda7c5d9299920432a0b3d5b009f5
|
||||
F src/vdbeapi.c fea41171884a4de119f8b10ab514c788674eeeb7f27218bb6d008e1310bfd07f
|
||||
F src/vdbeaux.c 2756ac68ac259c416554100598fc291870063288cd7e1af22847f57b3e130e56
|
||||
F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191
|
||||
F src/vdbemem.c 943e41881e6317c9f93c77c1d60d3b37ddc8d26a3f852233ce7423d3e581523e
|
||||
F src/vdbemem.c 21c1d00f0b901dda0a2eccf56bf0d86648cae1bde37de0606ae4e7cdb0ff6d3d
|
||||
F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2f
|
||||
F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c
|
||||
F src/vtab.c 0e4885495172e1bdf54b12cce23b395ac74ef5729031f15e1bc1e3e6b360ed1a
|
||||
@ -1704,7 +1704,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 88e2ce916791d488076584f3795a89eb4277fcb812af9e4c2f383815d55ff6f1
|
||||
R 59b5173dc10fbd02f5f4a286751c0af4
|
||||
U dan
|
||||
Z 2f13a257a067155eca38f77c87e4d0a0
|
||||
P e6bb750697c3c7ceb5ce41d216e8ef6a1d556822a3b55e0a007b4a03e194a7d9
|
||||
R 296950b2c8b3ce7a358fc83523609b8d
|
||||
U drh
|
||||
Z f52624ceb0e0d6c17658803080172034
|
||||
|
@ -1 +1 @@
|
||||
e6bb750697c3c7ceb5ce41d216e8ef6a1d556822a3b55e0a007b4a03e194a7d9
|
||||
5a70af1e9c567f12c997d25d0a305a8d42bf2cc92f2811e9d5fdde720665e213
|
@ -93,6 +93,51 @@ int sqlite3VdbeCheckMemInvariants(Mem *p){
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
/*
|
||||
** Check that string value of pMem agrees with its integer or real value.
|
||||
**
|
||||
** A single int or real value always converts to the same strings. But
|
||||
** many different strings can be converted into the same int or real.
|
||||
** If a table contains a numeric value and an index is based on the
|
||||
** corresponding string value, then it is important that the string be
|
||||
** derived from the numeric value, not the other way around, to ensure
|
||||
** that the index and table are consistent. See ticket
|
||||
** https://www.sqlite.org/src/info/343634942dd54ab (2018-01-31) for
|
||||
** an example.
|
||||
**
|
||||
** This routine looks at pMem to verify that if it has both a numeric
|
||||
** representation and a string representation then the string rep has
|
||||
** been derived from the numeric and not the other way around. It returns
|
||||
** true if everything is ok and false if there is a problem.
|
||||
**
|
||||
** This routine is for use inside of assert() statements only.
|
||||
*/
|
||||
int sqlite3VdbeMemConsistentDualRep(Mem *p){
|
||||
char zBuf[100];
|
||||
char *z;
|
||||
int i, j, incr;
|
||||
if( (p->flags & MEM_Str)==0 ) return 1;
|
||||
if( (p->flags & (MEM_Int|MEM_Real))==0 ) return 1;
|
||||
if( p->flags & MEM_Int ){
|
||||
sqlite3_snprintf(sizeof(zBuf),zBuf,"%lld",p->u.i);
|
||||
}else{
|
||||
sqlite3_snprintf(sizeof(zBuf),zBuf,"%!.15g",p->u.r);
|
||||
}
|
||||
z = p->z;
|
||||
i = j = 0;
|
||||
incr = 1;
|
||||
if( p->enc!=SQLITE_UTF8 ){
|
||||
incr = 2;
|
||||
if( p->enc==SQLITE_UTF16BE ) z++;
|
||||
}
|
||||
while( zBuf[j] ){
|
||||
if( zBuf[j++]!=z[i] ) return 0;
|
||||
i += incr;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif /* SQLITE_DEBUG */
|
||||
|
||||
/*
|
||||
** If pMem is an object with a valid string representation, this routine
|
||||
@ -1096,6 +1141,7 @@ static SQLITE_NOINLINE const void *valueToText(sqlite3_value* pVal, u8 enc){
|
||||
assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || pVal->db==0
|
||||
|| pVal->db->mallocFailed );
|
||||
if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){
|
||||
assert( sqlite3VdbeMemConsistentDualRep(pVal) );
|
||||
return pVal->z;
|
||||
}else{
|
||||
return 0;
|
||||
@ -1118,6 +1164,7 @@ const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
|
||||
assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );
|
||||
assert( (pVal->flags & MEM_RowSet)==0 );
|
||||
if( (pVal->flags&(MEM_Str|MEM_Term))==(MEM_Str|MEM_Term) && pVal->enc==enc ){
|
||||
assert( sqlite3VdbeMemConsistentDualRep(pVal) );
|
||||
return pVal->z;
|
||||
}
|
||||
if( pVal->flags&MEM_Null ){
|
||||
|
Loading…
x
Reference in New Issue
Block a user