From ed3e2b0d859bb7ff46e66cbf25ba6a8f61cdb6f3 Mon Sep 17 00:00:00 2001 From: Andrea Terzolo Date: Thu, 16 Nov 2023 18:13:40 +0100 Subject: [PATCH] fix(tests): remove a possible memleak from tests Signed-off-by: Andrea Terzolo --- userspace/libsinsp/test/sinsp_with_test_input.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/userspace/libsinsp/test/sinsp_with_test_input.h b/userspace/libsinsp/test/sinsp_with_test_input.h index d69a6bf8e70..716ef02ae96 100644 --- a/userspace/libsinsp/test/sinsp_with_test_input.h +++ b/userspace/libsinsp/test/sinsp_with_test_input.h @@ -411,7 +411,17 @@ class sinsp_with_test_input : public ::testing::Test { throw sinsp_exception("The event class is NULL"); } - return flist.new_filter_check_from_fldname(field_name, &m_inspector, false) != nullptr; + auto new_fl = flist.new_filter_check_from_fldname(field_name, &m_inspector, false); + if(new_fl != nullptr) + { + // if can create a filter check it means that the field exists + delete new_fl; + return true; + } + else + { + return false; + } } // Return true if `field_name` value is not NULL for this event.