diff options
author | Kristen Carlson Accardi <kristen@linux.intel.com> | 2010-03-24 10:13:23 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-03-24 13:21:31 -0700 |
commit | 954e114507741cece87fa8e6457899e70ab757a2 (patch) | |
tree | 988ec72a94bf0e421f6b9658ddb8a0392da68884 | |
parent | f6b286b44d1fbe7639644d7f7511fa96fc1e9030 (diff) | |
download | ofono-954e114507741cece87fa8e6457899e70ab757a2.tar.bz2 |
fix memory leaks in option handling
free the data as well as the link when deleting options lists.
-rw-r--r-- | gatchat/ppp_cp.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c index e8d6e309..0f04fa16 100644 --- a/gatchat/ppp_cp.c +++ b/gatchat/ppp_cp.c @@ -201,6 +201,16 @@ static void pppcp_clear_options(struct pppcp_data *data) data->rejected_options = NULL; } +static void pppcp_free_options(struct pppcp_data *data) +{ + /* remove all config options */ + pppcp_clear_options(data); + + /* remove default option list */ + g_list_foreach(data->config_options, pppcp_free_option, NULL); + g_list_free(data->config_options); +} + /* * set the restart counter to either max-terminate * or max-configure. The counter is decremented for @@ -1103,6 +1113,7 @@ static void remove_config_option(gpointer elem, gpointer user_data) if (!list) return; + g_free(list->data); data->config_options = g_list_delete_link(data->config_options, list); } @@ -1226,6 +1237,8 @@ static guint8 pppcp_process_configure_ack(struct pppcp_data *data, if (action->option_process) action->option_process(acked_option, data->priv); + + g_free(list->data); data->config_options = g_list_delete_link(data->config_options, list); } else @@ -1440,7 +1453,7 @@ void pppcp_free(struct pppcp_data *data) g_queue_free(data->event_queue); /* remove all config options */ - pppcp_clear_options(data); + pppcp_free_options(data); /* free self */ g_free(data); |