modem-helpers: ensure error is set when +CRM response parser doesn't match

This commit is contained in:
Aleksander Morgado
2013-04-24 23:05:12 +02:00
parent 1f99eaf80e
commit 40dc35a657

View File

@@ -2021,7 +2021,8 @@ mm_cdma_parse_crm_test_response (const gchar *reply,
{
gboolean result = FALSE;
GRegex *r;
GMatchInfo *match_info = NULL;
GError *match_error = NULL;
/* Expected reply format is:
* ---> AT+CRM=?
@@ -2031,10 +2032,9 @@ mm_cdma_parse_crm_test_response (const gchar *reply,
r = g_regex_new ("\\+CRM:\\s*\\((\\d+)-(\\d+)\\)",
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
0, error);
if (r) {
GMatchInfo *match_info = NULL;
g_assert (r != NULL);
if (g_regex_match_full (r, reply, strlen (reply), 0, 0, &match_info, error)) {
if (g_regex_match_full (r, reply, strlen (reply), 0, 0, &match_info, &match_error)) {
gchar *aux;
guint min_val = 0;
guint max_val = 0;
@@ -2065,11 +2065,18 @@ mm_cdma_parse_crm_test_response (const gchar *reply,
result = TRUE;
}
}
} else if (match_error) {
g_propagate_error (error, match_error);
} else {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Couldn't parse CRM range: response didn't match (%s)",
reply);
}
g_match_info_free (match_info);
g_regex_unref (r);
}
return result;
}