From 479dbd0f81ebe05cf15b59600c5062689abb7eb9 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Mon, 3 Sep 2018 15:32:21 +0530 Subject: [PATCH] Fixed memory leak g_ascii_strdown() returns a newly allocated string and should be freed with g_free(). Below is the valgrind report complaining about the leak ==7455== 216 bytes in 12 blocks are definitely lost in loss record 3,009 of 3,068 ==7455== at 0x48458A4: malloc (vg_replace_malloc.c:299) ==7455== by 0x4AB11B3: g_malloc (gmem.c:94) ==7455== by 0x4ACBF73: g_strndup (gstrfuncs.c:425) ==7455== by 0x4ACC9A7: g_ascii_strdown (gstrfuncs.c:1517) ==7455== by 0x12F0E7: __get_mac_address (wifi-config.c:180) ==7455== by 0x12F0E7: __get_group_name.constprop.4 (wifi-config.c:199) ==7455== by 0x12F75B: _load_configuration (wifi-config.c:312) ==7455== by 0x13133D: handle_load_configuration (wifi-config.c:1052) ==7455== by 0x4E40AF7: ffi_call_SYSV (in /usr/lib/libffi.so.6.0.2) Change-Id: I979c0daef4572a3a77a2f75e81ccfea0c8781fe0 Signed-off-by: Saurav Babu --- src/wifi-config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wifi-config.c b/src/wifi-config.c index afa0382..a53f705 100755 --- a/src/wifi-config.c +++ b/src/wifi-config.c @@ -151,6 +151,7 @@ static gboolean __get_mac_address(gchar **mac_address) } mac[12] = '\0'; *mac_address = g_strdup(mac); + g_free(tmp); return TRUE; } -- 2.34.1