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
This commit is contained in:
Nathan Williams
2011-09-27 13:40:39 -05:00
committed by Dan Williams
parent 00670456ff
commit 8710820156
11 changed files with 65 additions and 60 deletions

View File

@@ -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;
}