Skip to content

Commit

Permalink
ipconfig: Fix possible memory leak in ipconfig loading
Browse files Browse the repository at this point in the history
If we call __connman_ipconfig_load() for an existing and configured
ipconfig then there is a memory leak for ipaddress values.
Something like this can happen if the service is provisioned
using .config file.
  • Loading branch information
jukkar authored and pfl committed Sep 2, 2013
1 parent 55ec085 commit 110abe3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ipconfig.c
Expand Up @@ -2229,21 +2229,25 @@ int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
g_free(key);

key = g_strdup_printf("%slocal_address", prefix);
g_free(ipconfig->address->local);
ipconfig->address->local = g_key_file_get_string(
keyfile, identifier, key, NULL);
g_free(key);

key = g_strdup_printf("%speer_address", prefix);
g_free(ipconfig->address->peer);
ipconfig->address->peer = g_key_file_get_string(
keyfile, identifier, key, NULL);
g_free(key);

key = g_strdup_printf("%sbroadcast_address", prefix);
g_free(ipconfig->address->broadcast);
ipconfig->address->broadcast = g_key_file_get_string(
keyfile, identifier, key, NULL);
g_free(key);

key = g_strdup_printf("%sgateway", prefix);
g_free(ipconfig->address->gateway);
ipconfig->address->gateway = g_key_file_get_string(
keyfile, identifier, key, NULL);
g_free(key);
Expand Down

0 comments on commit 110abe3

Please sign in to comment.