--- a/src/json.c Sun Oct 20 12:30:30 2024 +0200 +++ b/src/json.c Tue Oct 22 12:16:16 2024 +0200 @@ -440,11 +440,6 @@ end_elm(p, CX_JSON_READER_ARRAY_END); break; } - case CX_JSON_TOKEN_END_OBJECT: { - p->value_ready = 0; - end_elm(p, CX_JSON_READER_OBJECT_END); - break; - } case CX_JSON_TOKEN_STRING: { p->reader_type = CX_JSON_READER_STRING; cxmutstr str = unescape_string(token.content, token.length); @@ -518,7 +513,7 @@ p->states[p->nstates] = 1; ret = json_read(p); } else if (state == 7) { - // expect ',' or '}]' + // expect ',' or '}' if (token.tokentype == CX_JSON_TOKEN_VALUE_SEPARATOR) { p->states[p->nstates] = JP_STATE_OBJ_NAME; ret = json_read(p); @@ -674,6 +669,7 @@ void cxJsonDestroy(CxJson *p) { free(p->states); free(p->readvalue_stack); + cxJsonValueFree(p->read_value); } void cxJsonFill(CxJson *p, const char *buf, size_t size) { @@ -699,6 +695,7 @@ if (p->readvalue_nelm > 0) { if (add_to_parent(p, p->readvalue_stack[p->readvalue_nelm - 1], v)) { + free(v); return -1; } } else {