diff options
author | drh <> | 2021-10-13 13:00:34 +0000 |
---|---|---|
committer | drh <> | 2021-10-13 13:00:34 +0000 |
commit | dbe349dfa5d705810de4783dd5417d7e9320981c (patch) | |
tree | dbcfe459b1a8664b0d2644242bba8b492f591b58 /src/vdbeapi.c | |
parent | 4fc80671f53f016d513bcb31b03e759b031d42bc (diff) | |
download | sqlite-dbe349dfa5d705810de4783dd5417d7e9320981c.tar.gz sqlite-dbe349dfa5d705810de4783dd5417d7e9320981c.zip |
The sqlite3_result_text() routine (and similar) should record OOM errors
in addition to SQLITE_TOOBIG errors.
dbsqlfuzz
FossilOrigin-Name: eca434362652fe2edd6090b29417b35bc88a170609810aa9d266f6fc27baeab8
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r-- | src/vdbeapi.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 5de7c64c2..5c4c321b3 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -362,8 +362,8 @@ void sqlite3_value_free(sqlite3_value *pOld){ ** the function result. ** ** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the -** result as a string or blob but if the string or blob is too large, it -** then sets the error code to SQLITE_TOOBIG +** result as a string or blob. Appropriate errors are set if the string/blob +** is too big or if an OOM occurs. ** ** The invokeValueDestructor(P,X) routine invokes destructor function X() ** on value P is not going to be used and need to be destroyed. @@ -375,8 +375,16 @@ static void setResultStrOrError( u8 enc, /* Encoding of z. 0 for BLOBs */ void (*xDel)(void*) /* Destructor function */ ){ - if( sqlite3VdbeMemSetStr(pCtx->pOut, z, n, enc, xDel)==SQLITE_TOOBIG ){ - sqlite3_result_error_toobig(pCtx); + int rc = sqlite3VdbeMemSetStr(pCtx->pOut, z, n, enc, xDel); + if( rc ){ + if( rc==SQLITE_TOOBIG ){ + sqlite3_result_error_toobig(pCtx); + }else{ + /* The only errors possible from sqlite3VdbeMemSetStr are + ** SQLITE_TOOBIG and SQLITE_NOMEM */ + assert( rc==SQLITE_NOMEM ); + sqlite3_result_error_nomem(pCtx); + } } } static int invokeValueDestructor( |