From c3722b2103f104a7d511c9fe4a831fb81c15c06c Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 23 Aug 2015 20:44:59 +0000 Subject: [PATCH] Fix minor glitches in the json1.c extension, mostly having to do with OOM behavior. FossilOrigin-Name: cc5204149c4053b9e529a72102d8df0925ad1ea1 --- ext/misc/json1.c | 10 +++++++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ext/misc/json1.c b/ext/misc/json1.c index d5d7d5a96c..ca22928302 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; } diff --git a/manifest b/manifest index 34b5e70a87..7429fea7cd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sto\sjson_each()\sand\sjson_tree().\s\sImproved\sjson_parse()\sdebugging\soutput. -D 2015-08-23T02:42:30.942 +C Fix\sminor\sglitches\sin\sthe\sjson1.c\sextension,\smostly\shaving\sto\sdo\swith\sOOM\nbehavior. +D 2015-08-23T20:44:59.358 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2218eb228374422969de7b1680eda6864affcef F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -192,7 +192,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767 F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e -F ext/misc/json1.c 31bc1babd31190203cb86fcdbe21522756f65b12 +F ext/misc/json1.c 4b66d2ce1dc458e214d0f3663a3870e592484230 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc @@ -1378,7 +1378,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 380a97345b446214843a63ccc017d49a52d884da -R a54dc4e155baa0caa5702a3578af52f1 +P fc1b24f316af07a64672f6edc14ebcff487dffbb +R f3f5a4cd7433351edd3f5e216e8c6ba5 U drh -Z b71b5a39d2829e2cd3b83f4646e372f9 +Z 19ea95791c67f4fad1659a43be075b46 diff --git a/manifest.uuid b/manifest.uuid index 29702aa763..db5d937671 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc1b24f316af07a64672f6edc14ebcff487dffbb \ No newline at end of file +cc5204149c4053b9e529a72102d8df0925ad1ea1 \ No newline at end of file