From 96b0596c8c9caa28040439e8e5389494406f331f Mon Sep 17 00:00:00 2001 From: awy Date: Sun, 24 Aug 2025 00:05:10 +0300 Subject: json tree cleanup --- src/sttorrent.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sttorrent.c b/src/sttorrent.c index 7a5a73c..a911071 100644 --- a/src/sttorrent.c +++ b/src/sttorrent.c @@ -140,7 +140,10 @@ main(void) torrents = cJSON_GetObjectItem(torrents, "arguments"); torrents = cJSON_GetObjectItem(torrents, "torrents"); - if (cJSON_GetArraySize(torrents) == 0) { return 0; } + if (cJSON_GetArraySize(torrents) == 0) { + cJSON_Delete(torrents); + return 0; + } /* Counting statuses */ for (int i = 0; i < cJSON_GetArraySize(torrents); i++) { @@ -165,5 +168,6 @@ main(void) printf("%d", status_count[i]); } + cJSON_Delete(torrents); return 0; } -- cgit v1.2.3