From 828368ae3aa672a2a667fffd43ef6f278a2e43d9 Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:25:02 +0800 Subject: [PATCH] fix(restful): invalid free --- src/parser/neu_json_tag.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/parser/neu_json_tag.c b/src/parser/neu_json_tag.c index 04f5c9d5..1cede062 100644 --- a/src/parser/neu_json_tag.c +++ b/src/parser/neu_json_tag.c @@ -336,7 +336,8 @@ int neu_json_decode_add_tags_req(char *buf, neu_json_add_tags_req_t **result) json_obj = neu_json_decode_new(buf); if (NULL == json_obj) { - goto decode_fail; + free(req); + return -1; } neu_json_elem_t req_elems[] = { @@ -545,7 +546,8 @@ int neu_json_decode_add_gtags_req(char *buf, neu_json_add_gtags_req_t **result) json_obj = neu_json_decode_new(buf); if (NULL == json_obj) { - goto decode_fail; + free(req); + return -1; } neu_json_elem_t req_elems[] = { @@ -681,6 +683,10 @@ int neu_json_decode_del_tags_req(char *buf, neu_json_del_tags_req_t **result) } json_obj = neu_json_decode_new(buf); + if (NULL == json_obj) { + free(req); + return -1; + } neu_json_elem_t req_elems[] = { { .name = "node", @@ -797,7 +803,8 @@ int neu_json_decode_update_tags_req(char * buf, json_obj = neu_json_decode_new(buf); if (NULL == json_obj) { - goto decode_fail; + free(req); + return -1; } neu_json_elem_t req_elems[] = {