From d043ea1d299e255a9e27d3eb1db97d1757353df9 Mon Sep 17 00:00:00 2001 From: Letter Date: Sun, 13 Sep 2020 14:49:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=97=A0=E6=95=88=E5=86=85=E5=AD=98=E9=87=8A=E6=94=BE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cson.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cson.c b/src/cson.c index 977ff57..de0b168 100644 --- a/src/cson.c +++ b/src/cson.c @@ -599,7 +599,7 @@ char* csonEncodeUnformatted(void *obj, CsonModel *model, int modelSize) void csonFree(void *obj, CsonModel *model, int modelSize) { CsonList *list, *p; - void *tmpNode; + int *tmpNode; for (short i = 0; i < modelSize; i++) { @@ -624,7 +624,15 @@ void csonFree(void *obj, CsonModel *model, int modelSize) list = list->next; if (p->obj) { - tmpNode = csonIsBasicListModel(model[i].param.sub.model) ? &(p->obj) : p->obj; + if (csonIsBasicListModel(model[i].param.sub.model)) + { + tmpNode = cson.malloc(sizeof(int)); + *tmpNode = (int)(&(p->obj)); + } + else + { + tmpNode = p->obj; + } csonFree(tmpNode, model[i].param.sub.model, model[i].param.sub.size); }