From f2a0461273db433feae04e98089479705c36baed Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Sat, 2 Dec 2023 15:07:33 +0000 Subject: [PATCH 1/3] jq_fuzz_execute: fix memory leak Signed-off-by: David Korczynski --- tests/jq_fuzz_execute.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/jq_fuzz_execute.cpp b/tests/jq_fuzz_execute.cpp index 223d4fe36a..112baaf59a 100644 --- a/tests/jq_fuzz_execute.cpp +++ b/tests/jq_fuzz_execute.cpp @@ -28,8 +28,11 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { } jv_free(next); } - - // Do not free "input" as this is handled by jq_teardown. + else { + // Only free if input as invalid as otherwise jq_teardown + // frees it. + jv_free(input); + } } } jq_teardown(&jq); From c8a8e94f9f9da5040b7fa8c086929351dd202f38 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Sat, 2 Dec 2023 16:04:52 +0000 Subject: [PATCH 2/3] Fix style Signed-off-by: David Korczynski --- tests/jq_fuzz_execute.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/jq_fuzz_execute.cpp b/tests/jq_fuzz_execute.cpp index 112baaf59a..feb2015009 100644 --- a/tests/jq_fuzz_execute.cpp +++ b/tests/jq_fuzz_execute.cpp @@ -27,8 +27,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { jv_free(actual); } jv_free(next); - } - else { + } else { // Only free if input as invalid as otherwise jq_teardown // frees it. jv_free(input); From cc08be3a0a4e624fe000463b261502fed6316e7f Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Sun, 3 Dec 2023 02:31:09 +0000 Subject: [PATCH 3/3] jq_fuzz_execute: fix typo Signed-off-by: David Korczynski --- tests/jq_fuzz_execute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jq_fuzz_execute.cpp b/tests/jq_fuzz_execute.cpp index feb2015009..66a044f380 100644 --- a/tests/jq_fuzz_execute.cpp +++ b/tests/jq_fuzz_execute.cpp @@ -28,7 +28,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { } jv_free(next); } else { - // Only free if input as invalid as otherwise jq_teardown + // Only free if input is invalid as otherwise jq_teardown // frees it. jv_free(input); }