Fixed memory leak 14/189714/1
authorSaurav Babu <saurav.babu@samsung.com>
Mon, 3 Sep 2018 10:02:21 +0000 (15:32 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Thu, 20 Sep 2018 04:05:15 +0000 (09:35 +0530)
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 <saurav.babu@samsung.com>
src/wifi-config.c

index afa0382..a53f705 100755 (executable)
@@ -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;
 }