diff options
author | Ben Chan <benchan@chromium.org> | 2013-12-09 15:07:26 -0800 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-12-10 10:26:57 +0100 |
commit | 4c213d460e446e69eb3265de3042e9e1582f1fd0 (patch) | |
tree | 48cffc525e39b7be50bfb16fa7acea772a6143da /src/mm-broadband-modem-mbim.c | |
parent | ebadb6786a4a398c0110c8e794922427081f10ee (diff) | |
download | ModemManager-4c213d460e446e69eb3265de3042e9e1582f1fd0.tar.gz |
broadband-modem-mbim: prevent potential leak when scanning networks
This patch addresses a potential memory leak when scan_networks in
MMBroadbandModemMbim is called but the caller does not provide a
GAsyncReadyCallback.
Reported by Aleksander Morgado <aleksander@lanedo.com>
Diffstat (limited to 'src/mm-broadband-modem-mbim.c')
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index b4d3ff1d8..774209eac 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -2308,10 +2308,25 @@ modem_3gpp_scan_networks_finish (MMIfaceModem3gpp *self, GAsyncResult *res, GError **error) { + MbimMessage *response; + MbimProvider **providers; + guint n_providers; + GList *info_list = NULL; + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) return NULL; - return g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)); + response = (MbimMessage *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)); + if (mbim_message_command_done_get_result (response, error) && + mbim_message_visible_providers_response_parse (response, + &n_providers, + &providers, + error)) { + info_list = mm_3gpp_network_info_list_from_mbim_providers ((const MbimProvider *const *)providers, + n_providers); + mbim_provider_array_free (providers); + } + return info_list; } static void @@ -2321,28 +2336,13 @@ visible_providers_query_ready (MbimDevice *device, { MbimMessage *response; GError *error = NULL; - MbimProvider **providers; - guint n_providers; response = mbim_device_command_finish (device, res, &error); - if (response && - mbim_message_command_done_get_result (response, &error) && - mbim_message_visible_providers_response_parse ( - response, - &n_providers, - &providers, - &error)) { - GList *info_list; - - info_list = mm_3gpp_network_info_list_from_mbim_providers ((const MbimProvider *const *)providers, - n_providers); - g_simple_async_result_set_op_res_gpointer (simple, info_list, NULL); - mbim_provider_array_free (providers); - } else + if (response) + g_simple_async_result_set_op_res_gpointer (simple, response, (GDestroyNotify)mbim_message_unref); + else g_simple_async_result_take_error (simple, error); - if (response) - mbim_message_unref (response); g_simple_async_result_complete (simple); g_object_unref (simple); } |