1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-22 22:13:04 +03:00

Fix a crash that could follow an OOM condition in the instr() SQL function.

FossilOrigin-Name: 6e59e903e4e956617bddef0b94e5cae02d724ac8145940b57ab5b0f628759736
This commit is contained in:
dan
2017-03-16 12:11:07 +00:00
parent 6f25936c9c
commit 116b56a2cc
4 changed files with 31 additions and 13 deletions

View File

@@ -204,9 +204,11 @@ static void instrFunc(
if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){
zHaystack = sqlite3_value_blob(argv[0]);
zNeedle = sqlite3_value_blob(argv[1]);
assert( zNeedle!=0 );
assert( zHaystack!=0 || nHaystack==0 );
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]);