aboutsummaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authordrh <>2023-08-30 18:19:40 +0000
committerdrh <>2023-08-30 18:19:40 +0000
commita7ec1f9a1b0415336079baa9a6073d37350c8331 (patch)
treea29470dec997162068ab96ee2d086224aa9824d1 /src/json.c
parent7bb5a6db4036e3956aadb71be0c390d3a4c32243 (diff)
downloadsqlite-a7ec1f9a1b0415336079baa9a6073d37350c8331.tar.gz
sqlite-a7ec1f9a1b0415336079baa9a6073d37350c8331.zip
Fix a bug in json_array_length() introduced in version 3.43.0 by
check-in [df099ad713011b67]. If the JSON input comes from json_remove(), the removed array entries are still counted as part of the array length. FossilOrigin-Name: 69a635958a4a14187e88dd297df8978a4805b1b0c7bff3ec29d5632c0f68d889
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/json.c b/src/json.c
index f8d4aa2a7..253fce9f4 100644
--- a/src/json.c
+++ b/src/json.c
@@ -2484,7 +2484,9 @@ static void jsonArrayLengthFunc(
}
if( pNode->eType==JSON_ARRAY ){
while( 1 /*exit-by-break*/ ){
- for(i=1; i<=pNode->n; n++){
+ i = 1;
+ while( i<=pNode->n ){
+ if( (pNode[i].jnFlags & JNODE_REMOVE)==0 ) n++;
i += jsonNodeSize(&pNode[i]);
}
if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;