瀏覽代碼

feat: set list head's prev in parse_array and parse_object

miaoerduo 5 年之前
父節點
當前提交
3999b12848
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      cJSON.c

+ 8 - 0
cJSON.c

@@ -1509,6 +1509,10 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
 success:
     input_buffer->depth--;
 
+    if (head != NULL) {
+        head->prev = current_item;
+    }
+
     item->type = cJSON_Array;
     item->child = head;
 
@@ -1681,6 +1685,10 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
 success:
     input_buffer->depth--;
 
+    if (head != NULL) {
+        head->prev = current_item;
+    }
+
     item->type = cJSON_Object;
     item->child = head;