summaryrefslogtreecommitdiff
path: root/dynotify.c
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2024-05-28 15:41:31 -0700
committerXiao Pan <gky44px1999@gmail.com>2024-05-28 15:41:31 -0700
commit9ff6b2b156cd8c899c8f871216358785e1c9b208 (patch)
tree7e132a91cd413c21dc2f2c7ef2eeb8a7ae0ec1a0 /dynotify.c
parentfe80f99c543281ae8ed6bf49ef11522ccb8f8152 (diff)
fix: dynotify: memory leak
Diffstat (limited to 'dynotify.c')
-rw-r--r--dynotify.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/dynotify.c b/dynotify.c
index 8061398..c77aeed 100644
--- a/dynotify.c
+++ b/dynotify.c
@@ -108,7 +108,9 @@ int main (void)
curl_easy_perform(curl);
//printf("%s\n",chunk.response);
- if (json_object_get_int(json_object_object_get(json_object_object_get(json_tokener_parse(chunk.response),"room"),"show_status")) == 1)
+ json_object *root;
+ root=json_tokener_parse(chunk.response);
+ if (json_object_get_int(json_object_object_get(json_object_object_get(root,"room"),"show_status")) == 1)
{
if(!room[i].up)
{
@@ -127,6 +129,8 @@ int main (void)
room[i].up=false;
free(chunk.response);
+ // must call json_object_put to free *root, else memory leak!
+ json_object_put(root);
}
sleep(60);
}