From 62d65a8a9ca181fcade36260814f8a14c442467a Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Tue, 18 Jul 2023 20:45:18 +0200 Subject: [PATCH] Fix memory leaks in --with-oniguruma=no implementation of f_match Found by LeakSanitizer running ./jq -n '"" | test("")' in a --with-oniguruma=no --enable-ubsan --enable-asan build. --- src/builtin.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/builtin.c b/src/builtin.c index 4ba3c4ad..b38d4c2f 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1022,6 +1022,10 @@ static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) { } #else /* !HAVE_LIBONIG */ static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) { + jv_free(input); + jv_free(regex); + jv_free(modifiers); + jv_free(testmode); return jv_invalid_with_msg(jv_string("jq was compiled without ONIGURUMA regex library. match/test/sub and related functions are not available.")); } #endif /* HAVE_LIBONIG */