From 1fbc590b26aa0f9b0144c4bbf99a0bf52fe31855 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 31 Dec 2021 10:49:22 +0100 Subject: [PATCH] Fix memory leaks in tests Tests were failing when run with ASAN enabled. --- app/tests/test_adb_parser.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/tests/test_adb_parser.c b/app/tests/test_adb_parser.c index fbc65649..cb3abb0e 100644 --- a/app/tests/test_adb_parser.c +++ b/app/tests/test_adb_parser.c @@ -11,6 +11,7 @@ static void test_get_ip_single_line() { char *ip = sc_adb_parse_device_ip_from_output(ip_route, sizeof(ip_route)); assert(ip); assert(!strcmp(ip, "192.168.12.34")); + free(ip); } static void test_get_ip_single_line_without_eol() { @@ -20,6 +21,7 @@ static void test_get_ip_single_line_without_eol() { char *ip = sc_adb_parse_device_ip_from_output(ip_route, sizeof(ip_route)); assert(ip); assert(!strcmp(ip, "192.168.12.34")); + free(ip); } static void test_get_ip_single_line_with_trailing_space() { @@ -29,6 +31,7 @@ static void test_get_ip_single_line_with_trailing_space() { char *ip = sc_adb_parse_device_ip_from_output(ip_route, sizeof(ip_route)); assert(ip); assert(!strcmp(ip, "192.168.12.34")); + free(ip); } static void test_get_ip_multiline_first_ok() { @@ -40,6 +43,7 @@ static void test_get_ip_multiline_first_ok() { char *ip = sc_adb_parse_device_ip_from_output(ip_route, sizeof(ip_route)); assert(ip); assert(!strcmp(ip, "192.168.1.2")); + free(ip); } static void test_get_ip_multiline_second_ok() { @@ -51,6 +55,7 @@ static void test_get_ip_multiline_second_ok() { char *ip = sc_adb_parse_device_ip_from_output(ip_route, sizeof(ip_route)); assert(ip); assert(!strcmp(ip, "192.168.1.3")); + free(ip); } static void test_get_ip_no_wlan() {