diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-07-20 21:20:25 -0700 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-07-20 21:20:25 -0700 |
commit | 83e66667d18a7f4c3ee5f1c9d79312ec2748e015 (patch) | |
tree | 8f58d49c1a2db5a099175089cd4048361c1bfc80 | |
parent | 41ac44c30b9d165dd90255eec5b817fc21b8f7ff (diff) | |
download | acron-83e66667d18a7f4c3ee5f1c9d79312ec2748e015.tar acron-83e66667d18a7f4c3ee5f1c9d79312ec2748e015.tar.gz acron-83e66667d18a7f4c3ee5f1c9d79312ec2748e015.tar.bz2 acron-83e66667d18a7f4c3ee5f1c9d79312ec2748e015.zip |
fix(libacron): JSON object not freed after deserialization
Signed-off-by: Trumeet <yuuta@yuuta.moe>
-rw-r--r-- | client/libacron/private/serializer.c | 12 |
1 files 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) { |