From: drh <> Date: Sat, 29 Apr 2023 16:31:08 +0000 (+0000) Subject: Simplification of the logic that normalizes JSON5 integer literals into X-Git-Tag: version-3.42.0~73^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=399875f6c568bf7e674948c09686c0c7cabb21d9;p=thirdparty%2Fsqlite.git Simplification of the logic that normalizes JSON5 integer literals into canonical JSON integer literals. Improved reporting of OOM. FossilOrigin-Name: 01ee613c07fcb87e7d7b7f1b1387982715d1343418f37f4a1dc90e43a76d20e8 --- diff --git a/manifest b/manifest index bd3882b93b..3a9b1fb48b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sallow\sleading\szeros\son\snon-zero\snumeric\sliterals\sin\sJSON. -D 2023-04-29T16:00:20.514 +C Simplification\sof\sthe\slogic\sthat\snormalizes\sJSON5\sinteger\sliterals\sinto\ncanonical\sJSON\sinteger\sliterals.\s\sImproved\sreporting\sof\sOOM. +D 2023-04-29T16:31:08.205 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -594,7 +594,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51 F src/hwtime.h b638809e083b601b618df877b2e89cb87c2a47a01f4def10be4c4ebb54664ac7 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/insert.c a8de1db43335fc4946370a7a7e47d89975ad678ddb15078a150e993ba2fb37d4 -F src/json.c 1de9706f7bc22865237fa46a2f3e0de320e0a6afa24ff7b854c7522c0cc57c48 +F src/json.c 6029d4ce8705ebad5817386a326b620772dcc165e1b23a8e4645061621679538 F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/loadext.c be5af440f3192c58681b5d43167dbca3ccbfce394d89faa22378a14264781136 F src/main.c 09bc5191f75dc48fc4dfddda143cb864c0c3dbc3297eb9a9c8e01fea58ff847d @@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2fe684cdcdc3cab4ec3348ca5aa5948e4472c562b739c29faebcb77397f8d969 -R ab5a5b4f8c2b54ec0b250293ed522d33 +P 3e91494390ba88498eb243f61ce4ef4efa23b58326108a769bc72331d7d7d75b +R 9934ae2414640783ca534819ca587694 U drh -Z 69b4a1c1b9499f71fc838cb1772a2121 +Z fec85eb0c6f9c0d91d036f5cadb9198f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index b758f33f29..beb328db1e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e91494390ba88498eb243f61ce4ef4efa23b58326108a769bc72331d7d7d75b \ No newline at end of file +01ee613c07fcb87e7d7b7f1b1387982715d1343418f37f4a1dc90e43a76d20e8 \ No newline at end of file diff --git a/src/json.c b/src/json.c index f603a82bf7..17908fd976 100644 --- a/src/json.c +++ b/src/json.c @@ -371,21 +371,17 @@ static void jsonAppendNormalizedInt(JsonString *p, const char *zIn, u32 N){ zIn++; N--; } - while( zIn[0]=='0' && N>1 ){ - if( zIn[1]=='x' || zIn[1]=='X' ){ - sqlite3_int64 i = 0; - int rc = sqlite3DecOrHexToI64(zIn, &i); - if( rc<=1 ){ - jsonPrintf(100,p,"%lld",i); - }else{ - assert( rc==2 ); - jsonAppendRaw(p, "9.0e999", 7); - } - return; + if( zIn[0]=='0' && (zIn[1]=='x' || zIn[1]=='X') ){ + sqlite3_int64 i = 0; + int rc = sqlite3DecOrHexToI64(zIn, &i); + if( rc<=1 ){ + jsonPrintf(100,p,"%lld",i); + }else{ + assert( rc==2 ); + jsonAppendRaw(p, "9.0e999", 7); } - zIn++; - N--; - } + return; + } jsonAppendRaw(p, zIn, N); } @@ -2571,8 +2567,13 @@ static void jsonValidFunc( JsonParse *p; /* The parse */ UNUSED_PARAMETER(argc); p = jsonParseCached(ctx, argv, 0); - sqlite3_result_int(ctx, p!=0 && p->nErr==0 && p->has5==0); - if( p!=0 && p->nErr ) jsonParseFree(p); + if( p==0 || p->oom ){ + sqlite3_result_error_nomem(ctx); + sqlite3_free(p); + }else{ + sqlite3_result_int(ctx, p->nErr==0 && p->has5==0); + if( p->nErr ) jsonParseFree(p); + } } @@ -2590,8 +2591,13 @@ static void jsonValid5Func( JsonParse *p; /* The parse */ UNUSED_PARAMETER(argc); p = jsonParseCached(ctx, argv, 0); - sqlite3_result_int(ctx, p!=0 && p->nErr==0); - if( p!=0 && p->nErr ) jsonParseFree(p); + if( p==0 || p->oom ){ + sqlite3_result_error_nomem(ctx); + sqlite3_free(p); + }else{ + sqlite3_result_int(ctx, p->nErr==0); + if( p->nErr ) jsonParseFree(p); + } } @@ -2611,7 +2617,10 @@ static void jsonErrorFunc( JsonParse *p; /* The parse */ UNUSED_PARAMETER(argc); p = jsonParseCached(ctx, argv, 0); - if( p==0 || p->oom || p->nErr==0 ){ + if( p==0 || p->oom ){ + sqlite3_result_error_nomem(ctx); + sqlite3_free(p); + }else if( p->nErr==0 ){ sqlite3_result_int(ctx, 0); }else{ int n = 1;