diff options
author | drh <drh@noemail.net> | 2019-02-22 15:42:10 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-02-22 15:42:10 +0000 |
commit | 255a81f10a5885a17d99ea20e13e1641029e6e3b (patch) | |
tree | 7db3d75f00d5dbd4d410b6e62078de198c6410dc /src | |
parent | dbdddc99d83130fe22ed63a4bfc19a53a408c51b (diff) | |
download | sqlite-255a81f10a5885a17d99ea20e13e1641029e6e3b.tar.gz sqlite-255a81f10a5885a17d99ea20e13e1641029e6e3b.zip |
Modify sqlite3_str_finish() and sqlite3VMPrintf() so that they always
return NULL on any OOM or SQLITE_LIMIT_LENGTH error.
FossilOrigin-Name: e7144ffd21294d7aebbfa6aa5a262797a6d16de11193f1bf6b75f5f27b04c940
Diffstat (limited to 'src')
-rw-r--r-- | src/printf.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/printf.c b/src/printf.c index f11fb6664..3a12f51b3 100644 --- a/src/printf.c +++ b/src/printf.c @@ -136,7 +136,7 @@ static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){ static void setStrAccumError(StrAccum *p, u8 eError){ assert( eError==SQLITE_NOMEM || eError==SQLITE_TOOBIG ); p->accError = eError; - p->nAlloc = 0; + if( p->mxAlloc ) sqlite3_str_reset(p); } /* @@ -166,6 +166,7 @@ static char *getTextArg(PrintfArguments *p){ */ static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){ char *z; + if( pAccum->accError ) return 0; if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){ setStrAccumError(pAccum, SQLITE_TOOBIG); return 0; @@ -885,9 +886,8 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ return 0; } if( p->mxAlloc==0 ){ - N = p->nAlloc - p->nChar - 1; setStrAccumError(p, SQLITE_TOOBIG); - return N; + return p->nAlloc - p->nChar - 1; }else{ char *zOld = isMalloced(p) ? p->zText : 0; i64 szNew = p->nChar; @@ -959,7 +959,7 @@ void sqlite3_str_append(sqlite3_str *p, const char *z, int N){ assert( z!=0 || N==0 ); assert( p->zText!=0 || p->nChar==0 || p->accError ); assert( N>=0 ); - assert( p->accError==0 || p->nAlloc==0 ); + assert( p->accError==0 || p->nAlloc==0 || p->mxAlloc==0 ); if( p->nChar+N >= p->nAlloc ){ enlargeAndAppend(p,z,N); }else if( N ){ |