Skip to content

Commit d3c262a

Browse files
author
D. Richard Hipp
committed
The sqlite3_str_new() interface never returns NULL, even after an OOM.
Code that uses that interface should invoke sqlite3_str_errcode() to see if an OOM has occurred.
1 parent 9c51197 commit d3c262a

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

ext/misc/analyze.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,10 @@ static void analyzeFunc(
433433
s.db = sqlite3_context_db_handle(context);
434434
s.context = context;
435435
s.pOut = sqlite3_str_new(0);
436-
if( s.pOut==0 ){ analysisError(&s, 0); return; }
436+
if( sqlite3_str_errcode(s.pOut) ){
437+
analysisError(&s, 0);
438+
return;
439+
}
437440
s.zSchema = (const char*)sqlite3_value_text(argv[0]);
438441
if( s.zSchema==0 ){
439442
s.zSchema = "main";

src/func.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,7 +3106,7 @@ static void filestatFunc(
31063106
assert( pPager!=0 );
31073107
fd = sqlite3PagerFile(pPager);
31083108
pStr = sqlite3_str_new(db);
3109-
if( pStr==0 ){
3109+
if( sqlite3_str_errcode(pStr) ){
31103110
sqlite3_result_error_nomem(context);
31113111
}else{
31123112
sqlite3_str_append(pStr, "{\"db\":", 6);
@@ -3209,7 +3209,7 @@ static void parseuriFunc(
32093209
flgs = (unsigned int)sqlite3_value_int(argv[1]);
32103210
rc = sqlite3ParseUri(zVfs, zUri, &flgs, &pVfs, &zFile, &zErr);
32113211
pResult = sqlite3_str_new(0);
3212-
if( pResult ){
3212+
if( !sqlite3_str_errcode(pResult) ){
32133213
int i;
32143214
sqlite3_str_appendf(pResult, "rc=%d", rc);
32153215
sqlite3_str_appendf(pResult, ", flags=0x%x", flgs);

0 commit comments

Comments
 (0)