aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2021-07-15 11:32:05 +0200
committerKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2021-07-19 12:53:25 +0200
commitaf175fed75eafcb38d9f674fe260bef0ddbb0875 (patch)
tree2c1f2238ace05a0eeadc065ccdd72f5c8160375d
parentfc99f821766a413618bb9fbc008e56463e757026 (diff)
downloadneard-af175fed75eafcb38d9f674fe260bef0ddbb0875.tar.gz
unit: fix memory leaks in test-ndef-build
test-ndef-build.c was not freeing the ndef records it got leading to memory leaks. Report by valgrind: (24 direct, 15 indirect) bytes in 1 blocks are definitely lost in loss record 24 of 38 at 0x483ED99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x11C176: ndef_message_alloc_complete.constprop.0 (ndef.c:1654) by 0x11FEC5: ndef_message_alloc (ndef.c:1760) by 0x11FEC5: near_ndef_prepare_text_record (ndef.c:3142) by 0x121676: test_ndef_text_build (test-ndef-build.c:63) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F5A1: main (test-ndef-build.c:113) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
-rw-r--r--unit/test-ndef-build.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/unit/test-ndef-build.c b/unit/test-ndef-build.c
index 44dce4b..54b502f 100644
--- a/unit/test-ndef-build.c
+++ b/unit/test-ndef-build.c
@@ -65,6 +65,8 @@ static void test_ndef_text_build(void)
g_assert(ndef);
g_assert_cmpuint(ndef->length, ==, ARRAY_SIZE(text));
g_assert_cmpmem(ndef->data, ARRAY_SIZE(text), text, ARRAY_SIZE(text));
+
+ near_ndef_msg_free(ndef);
}
static void test_ndef_wsc_with_passphrase_build(void)
@@ -76,6 +78,8 @@ static void test_ndef_wsc_with_passphrase_build(void)
g_assert(ndef);
g_assert_cmpuint(ndef->length, ==, ARRAY_SIZE(wsc));
g_assert_cmpmem(ndef->data, ARRAY_SIZE(wsc), wsc, ARRAY_SIZE(wsc));
+
+ near_ndef_msg_free(ndef);
}
static void test_ndef_wsc_with_out_passphrase_build(void)
@@ -87,6 +91,8 @@ static void test_ndef_wsc_with_out_passphrase_build(void)
g_assert(ndef);
g_assert_cmpuint(ndef->length, ==, ARRAY_SIZE(wsc_wo));
g_assert_cmpmem(ndef->data, ARRAY_SIZE(wsc_wo), wsc_wo, ARRAY_SIZE(wsc_wo));
+
+ near_ndef_msg_free(ndef);
}
static void test_ndef_wsc_with_out_ssid_build(void)