From bff23d15d41a42c7b5f43cb3d18d66e7cd289823 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 3 Sep 2020 11:35:40 +0200 Subject: [PATCH] initrd/tests: fix memleak in test_dhcp_vendor_class_id() Having leaks in the tests, breaks running the test under valgrind. There must be no leaks. Fixes: c056cb9306be ('initrd: parse 'rd.net.dhcp.vendor-class' kernel cmdline arg') --- src/initrd/tests/test-cmdline-reader.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c index a909bc3802..a11b76e015 100644 --- a/src/initrd/tests/test-cmdline-reader.c +++ b/src/initrd/tests/test-cmdline-reader.c @@ -1508,6 +1508,8 @@ test_dhcp_vendor_class_id (void) s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting_ip4_config (connection)); g_assert_cmpstr (nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4), ==, "testvci"); + nm_clear_pointer (&connections, g_hash_table_unref); + ARGV = NM_MAKE_STRV ("rd.net.dhcp.vendor-class", "ip=eno1:dhcp"); connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname); @@ -1517,7 +1519,7 @@ test_dhcp_vendor_class_id (void) s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting_ip4_config (connection)); g_assert (nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4) == NULL); - + nm_clear_pointer (&connections, g_hash_table_unref); memset (vci_arg_long, 'A', 400); vci_long = g_strdup_printf ("rd.net.dhcp.vendor-class=%s", vci_arg_long);