From e2f132e9893a27f23a299344237d105a7975fc69 Mon Sep 17 00:00:00 2001 From: Kyeonghun Lee Date: Wed, 8 Feb 2017 13:43:38 +0900 Subject: fix svace issue Change-Id: Ib211a511d3eb6bebb0165e1206821f28dc090e8c Signed-off-by: Kyeonghun Lee --- utils/MsgJsonParser.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils/MsgJsonParser.cpp b/utils/MsgJsonParser.cpp index 90f2baf..49d5fdd 100755 --- a/utils/MsgJsonParser.cpp +++ b/utils/MsgJsonParser.cpp @@ -44,7 +44,11 @@ msg_json_gen_object* msg_json_gen_new_obj(msg_json_gen_type type) new_obj = (msg_json_gen_object *)g_try_malloc0(sizeof(msg_json_gen_object)); if (new_obj == NULL) { - g_object_unref(json_value); + if (type == MSG_JSON_GEN_OBJECT) + g_object_unref(json_value); + else if (type == MSG_JSON_GEN_ARRAY) + g_array_unref((GArray *)json_value); + return NULL; } @@ -61,7 +65,11 @@ void msg_json_gen_free_obj(msg_json_gen_object *obj) return; } if (obj->value != NULL) { - g_object_unref(obj->value); + if (obj->type == MSG_JSON_GEN_OBJECT) + g_object_unref(obj->value); + else if (obj->type == MSG_JSON_GEN_ARRAY) + g_array_unref((GArray *)obj->value); + obj->value = NULL; } g_free(obj); -- cgit v1.2.3