修复 一个无效内存释放的问题

This commit is contained in:
Letter 2020-09-13 14:49:48 +08:00
parent 40a830ddcd
commit d043ea1d29
1 changed files with 10 additions and 2 deletions

View File

@ -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);
}