diff options
author | Nathan Williams <njw@chromium.org> | 2011-09-27 13:40:39 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-09-27 13:40:39 -0500 |
commit | 8710820156f51d1861b329e6fc12e706304ddda9 (patch) | |
tree | 21fd334c5023fc0aa15a4023b5b10177a6e51ba4 /src/mm-modem-helpers.c | |
parent | 00670456ffb4b08af3620a95c73601bc15d84eb9 (diff) |
core: ensure that GMatchInfo and GRegex objects are freed properly
In particular, g_regex_match() and g_regex_match_full() allocate a
match_info structure on both success and failure, so calling
g_match_info_free() only in the success case is insufficient.
BUG=None
TEST=Inspection
Change-Id: Iea76b5b5dc3ec48120e15601a5e2dd45322133d8
Diffstat (limited to 'src/mm-modem-helpers.c')
-rw-r--r-- | src/mm-modem-helpers.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index f6a0ffa3..66c3fb64 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -125,10 +125,8 @@ mm_gsm_parse_scan_response (const char *reply, GError **error) /* If we didn't get any hits, try the pre-UMTS format match */ if (!g_regex_match (r, reply, 0, &match_info)) { g_regex_unref (r); - if (match_info) { - g_match_info_free (match_info); - match_info = NULL; - } + g_match_info_free (match_info); + match_info = NULL; /* Pre-UMTS format doesn't include the cell access technology after * the numeric operator element. @@ -778,8 +776,8 @@ mm_gsm_parse_cscs_support_response (const char *reply, g_match_info_next (match_info, NULL); success = TRUE; } - g_match_info_free (match_info); } + g_match_info_free (match_info); g_regex_unref (r); if (success) @@ -1020,8 +1018,8 @@ mm_parse_cind_test_response (const char *reply, GError **error) g_match_info_next (match_info, NULL); } - g_match_info_free (match_info); } + g_match_info_free (match_info); g_regex_unref (r); return hash; @@ -1086,11 +1084,10 @@ mm_parse_cind_query_response(const char *reply, GError **error) g_free (str); g_match_info_next (match_info, NULL); } - g_match_info_free (match_info); done: - if (r) - g_regex_unref (r); + g_match_info_free (match_info); + g_regex_unref (r); return array; } |