Simplified OOM detection in the instr() SQL function.

FossilOrigin-Name: 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f
This commit is contained in:
drh 2017-03-16 14:28:52 +00:00
parent 85c2dc0ae6
commit b30574bcae
3 changed files with 8 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C Fix\san\suninitialized\svariable\sreference\sin\sthe\stext\sgenerator\s\nfor\s"PRAGMA\svdbe_trace=ON"\soutput.\nProblem\sdiscovered\sby\sOSS-Fuzz.
D 2017-03-16T13:30:58.522
C Simplified\sOOM\sdetection\sin\sthe\sinstr()\sSQL\sfunction.
D 2017-03-16T14:28:52.423
F Makefile.in 9605f4c49eace601d5c12c85dd6e037cc613a6d823e857614ba26b42f1285db0
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 1faf9f06aadc9284c212dea7bbc7c0dea7e8337f0287c81001eff500912c790a
@ -356,7 +356,7 @@ F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c
F src/expr.c f12a581f342a6fd85d14c31e4fb84f16b3dd107f54d7728dddb62cebc79d7ce1
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae
F src/func.c 72ed1518f59951daca3b3480331006f074041b4753ab652b46bbdaedb77f6d6c
F src/func.c 9d52522cc8ae7f5cdadfe14594262f1618bc1f86083c4cd6da861b4cf5af6174
F src/global.c 4a34512d82fc5aa13c802db06bcfff5e1d3de955
F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
@ -1565,7 +1565,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 eb7680a1c047b2a33d6a0c9733fafaee11272377c627af10bbd541b6b7ed952b
R 698ee80038f5639a9fb93e688b92867d
P e3d487162d1596ce125644f754ed9531ef4412f31f6837c3e31b7542b90602fe
R 6130240157d02268edef1462c36002d9
U drh
Z 1c91cacf813bcc1311ca42c9e29c59cd
Z 5ff31e1a870d72447c943f18c5a0c832

View File

@ -1 +1 @@
e3d487162d1596ce125644f754ed9531ef4412f31f6837c3e31b7542b90602fe
6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f

View File

@ -205,16 +205,12 @@ static void instrFunc(
zHaystack = sqlite3_value_blob(argv[0]);
zNeedle = sqlite3_value_blob(argv[1]);
isText = 0;
/* The following condition may be true if the arguments passed to this
** function are values returned by zeroblob() or similar and an OOM
** occurs while expanding the blob value. */
if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;
}else{
zHaystack = sqlite3_value_text(argv[0]);
zNeedle = sqlite3_value_text(argv[1]);
isText = 1;
if( zHaystack==0 || zNeedle==0 ) return;
}
if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;
while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){
N++;
do{