]> git.feebdaed.xyz Git - 0xmirror/cJSON.git/commitdiff
Fix heap buffer overflow
authororri <orri@systemb.is>
Tue, 30 Apr 2024 09:50:19 +0000 (09:50 +0000)
committerAlan Wang <wp_scut@163.com>
Mon, 6 May 2024 03:33:33 +0000 (11:33 +0800)
Fixes #800

cJSON.c

diff --git a/cJSON.c b/cJSON.c
index 4f5b38dc94d868674d779107f971b7ffe5ab01e5..97564bb0a9111b4487139346e4af2a955aae6de2 100644 (file)
--- a/cJSON.c
+++ b/cJSON.c
@@ -1660,6 +1660,11 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
             current_item = new_item;
         }
 
+        if (cannot_access_at_index(input_buffer, 1))
+        {
+            goto fail; /* nothing comes after the comma */
+        }
+
         /* parse the name of the child */
         input_buffer->offset++;
         buffer_skip_whitespace(input_buffer);