From 83e66667d18a7f4c3ee5f1c9d79312ec2748e015 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Wed, 20 Jul 2022 21:20:25 -0700 Subject: fix(libacron): JSON object not freed after deserialization Signed-off-by: Trumeet --- client/libacron/private/serializer.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/client/libacron/private/serializer.c b/client/libacron/private/serializer.c index c5b1b17..3517fc2 100644 --- a/client/libacron/private/serializer.c +++ b/client/libacron/private/serializer.c @@ -237,9 +237,6 @@ static int deserialize_response(json_object *obj, const char *type_str, const in } return AC_E_OK; fail: - if (obj) { - json_object_put(obj); - } return r; } @@ -373,9 +370,6 @@ static int deserialize_event(json_object *obj, const char *type_str, ac_event_t return AC_E_OK; fail: - if (obj) { - json_object_put(obj); - } return r; } @@ -398,10 +392,12 @@ int deserialize(const char *string, unsigned int len, ac_obj_t **out) { } if (has_id) { - return deserialize_response(obj, type_str, id, (ac_response_t **) out); + r = deserialize_response(obj, type_str, id, (ac_response_t **) out); } else { - return deserialize_event(obj, type_str, (ac_event_t **) out); + r = deserialize_event(obj, type_str, (ac_event_t **) out); } + json_object_put(obj); + return r; } static int json_add(json_object *obj, const char *key, json_object *val) { -- cgit v1.2.3