# HG changeset patch
# User miaoerduo <zhaoyu3210@foxmail.com>
# Date 1585894042 -28800
#      Fri Apr 03 14:07:22 2020 +0800
# Node ID 4588f15d4fb4165b1b84753c5fbaaac82ae868be
# Parent  8777557d3b9724960dab07fe9eef1ccc1cacd612
fix: error list head's prev when detach the last item

diff --git a/cJSON.c b/cJSON.c
--- a/cJSON.c
+++ b/cJSON.c
@@ -2210,6 +2210,12 @@
         /* first element */
         parent->child = item->next;
     }
+    else if (item->next == NULL)
+    {
+        /* last element */
+        parent->child->prev = item->prev;
+    }
+
     /* make sure the detached item doesn't point anywhere anymore */
     item->prev = NULL;
     item->next = NULL;