]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/unit/test-util-sockets: fix mem-leak on error object
authorMatheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Mon, 26 May 2025 17:20:55 +0000 (10:20 -0700)
committerThomas Huth <thuth@redhat.com>
Fri, 30 May 2025 07:52:08 +0000 (09:52 +0200)
The test fails with --enable-asan as the error struct is never freed.
In the case where the test expects a success but it fails, let's also
report the error for debugging (it will be freed internally).

Fixes 316e8ee8d6 ("util/qemu-sockets: Refactor inet_parse() to use QemuOpts")

Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Message-ID: <518d94c7db20060b2a086cf55ee9bffab992a907.1748280011.git.matheus.bernardino@oss.qualcomm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/unit/test-util-sockets.c

index 8492f4d68f279e2c7f4503b388d2578478a92b75..ee66d727c388e7e42130e850334587e49d284130 100644 (file)
@@ -341,8 +341,12 @@ static void inet_parse_test_helper(const char *str,
     int rc = inet_parse(&addr, str, &error);
 
     if (success) {
+        if (error) {
+            error_report_err(error);
+        }
         g_assert_cmpint(rc, ==, 0);
     } else {
+        error_free(error);
         g_assert_cmpint(rc, <, 0);
     }
     if (exp_addr != NULL) {