diff options
author | drh <drh@noemail.net> | 2015-08-23 20:44:59 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-08-23 20:44:59 +0000 |
commit | c3722b2103f104a7d511c9fe4a831fb81c15c06c (patch) | |
tree | cbbd9b292e2f7db61c0687df80b1a4cd69246a40 /ext/misc/json1.c | |
parent | 8784eca17f029b709852e8ca8aabfe73d7baf6f1 (diff) | |
download | sqlite-c3722b2103f104a7d511c9fe4a831fb81c15c06c.tar.gz sqlite-c3722b2103f104a7d511c9fe4a831fb81c15c06c.zip |
Fix minor glitches in the json1.c extension, mostly having to do with OOM
behavior.
FossilOrigin-Name: cc5204149c4053b9e529a72102d8df0925ad1ea1
Diffstat (limited to 'ext/misc/json1.c')
-rw-r--r-- | ext/misc/json1.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/misc/json1.c b/ext/misc/json1.c index d5d7d5a96..ca2292830 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -703,10 +703,11 @@ static int jsonParse( const char *zJson /* Input JSON text to be parsed */ ){ int i; - if( zJson==0 ) return 1; memset(pParse, 0, sizeof(*pParse)); + if( zJson==0 ) return 1; pParse->zJson = zJson; i = jsonParseValue(pParse, 0); + if( pParse->oom ) i = -1; if( i>0 ){ while( isspace(zJson[i]) ) i++; if( zJson[i] ) i = -1; @@ -753,7 +754,10 @@ static int jsonParseFindParents(JsonParse *pParse){ u32 *aUp; assert( pParse->aUp==0 ); aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode ); - if( aUp==0 ) return SQLITE_NOMEM; + if( aUp==0 ){ + pParse->oom = 1; + return SQLITE_NOMEM; + } jsonParseFillInParentage(pParse, 0, 0); return SQLITE_OK; } @@ -1672,8 +1676,8 @@ static int jsonEachFilter( p->eType = pNode->eType; if( p->eType>=JSON_ARRAY ){ pNode->u.iKey = 0; + p->iEnd = p->i + pNode->n + 1; if( !p->bRecursive ) p->i++; - p->iEnd = p->i + pNode->n; }else{ p->iEnd = p->i+1; } |