diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2010-07-09 23:34:32 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-07-09 23:38:39 +0200 |
commit | a0a70f029190cce180e811b8b307ff3ccf4a7652 (patch) | |
tree | 4a5ce02d0f256176404f565fd98365e2c3d981d1 /src | |
parent | d1070265d015218887368117c3a69169dc9df5c5 (diff) | |
download | connman-a0a70f029190cce180e811b8b307ff3ccf4a7652.tar.gz connman-a0a70f029190cce180e811b8b307ff3ccf4a7652.tar.bz2 connman-a0a70f029190cce180e811b8b307ff3ccf4a7652.zip |
Fix connman_wifi_load_ssid
The returned string array must be NULL terminated, and the groups array
should be freed as well.
Diffstat (limited to 'src')
-rw-r--r-- | src/wifi.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -68,12 +68,10 @@ char **connman_wifi_load_ssid(void) return NULL; groups = g_key_file_get_groups(key_file, &num_groups); - if (groups == NULL) { - hex_ssids = NULL; - goto done; - } - hex_ssids = g_try_malloc0(sizeof(*hex_ssids) * num_groups); + hex_ssids = g_try_malloc0(sizeof(*hex_ssids) * (num_groups + 1)); + if (hex_ssids == NULL) + goto done; for (i = 0, j = 0; groups[i]; i++) { gchar *hex_ssid; @@ -94,7 +92,11 @@ char **connman_wifi_load_ssid(void) hex_ssids[j++] = hex_ssid; } + hex_ssids[j] = NULL; + done: + g_strfreev(groups); + __connman_storage_close_profile(profile, key_file, FALSE); return hex_ssids; |