diff --git a/cJSON.c b/cJSON.c index a198d66..b3af058 100644 --- a/cJSON.c +++ b/cJSON.c @@ -2117,6 +2117,11 @@ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const it /* not the last element */ item->next->prev = item->prev; } + else + { + /* the last element - need to fix the prev pointer of the 1st element */ + parent->child->prev = item->prev; + } if (item == parent->child) {