From db4635a081b03eb9a2ea310bfb2f994fd9d4ee94 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 31 Jan 2022 23:53:50 +0100 Subject: jplist: Fix memory leak that occurs when JSON parsing fails Credit to OSS-Fuzz --- .../clusterfuzz-testcase-minimized-jplist_fuzzer-5069883912617984 | 1 + src/jplist.c | 1 + 2 files changed, 2 insertions(+) create mode 100644 fuzz/jplist-leaks/clusterfuzz-testcase-minimized-jplist_fuzzer-5069883912617984 diff --git a/fuzz/jplist-leaks/clusterfuzz-testcase-minimized-jplist_fuzzer-5069883912617984 b/fuzz/jplist-leaks/clusterfuzz-testcase-minimized-jplist_fuzzer-5069883912617984 new file mode 100644 index 0000000..a1f85f7 --- /dev/null +++ b/fuzz/jplist-leaks/clusterfuzz-testcase-minimized-jplist_fuzzer-5069883912617984 @@ -0,0 +1 @@ +{""A} \ No newline at end of file diff --git a/src/jplist.c b/src/jplist.c index 827b367..65eb528 100644 --- a/src/jplist.c +++ b/src/jplist.c @@ -663,6 +663,7 @@ static plist_t parse_object(const char* js, jsmntok_info_t* ti, int* index) if (val) { plist_dict_set_item(obj, key, val); } else { + free(key); plist_free(obj); return NULL; } -- cgit v1.1-32-gdbae