From b0746c591f052587999ca22b81b86f1e8dd56354 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 27 Nov 2012 22:04:04 +0100 Subject: [PATCH] huawei: don't assume g_regex_match_full() sets error when not matching --- plugins/huawei/mm-broadband-modem-huawei.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c index 0ee81be3..2f745c0d 100644 --- a/plugins/huawei/mm-broadband-modem-huawei.c +++ b/plugins/huawei/mm-broadband-modem-huawei.c @@ -116,6 +116,7 @@ load_access_technologies_finish (MMIfaceModem *self, GRegex *r; GMatchInfo *match_info = NULL; gint srv_stat = 0; + GError *inner_error = NULL; result = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error); if (!result) @@ -125,8 +126,19 @@ load_access_technologies_finish (MMIfaceModem *self, r = g_regex_new ("\\^SYSINFO:\\s*(\\d?),(\\d?),(\\d?),(\\d?),(\\d?),(\\d?),(\\d?)$", G_REGEX_UNGREEDY, 0, NULL); g_assert (r != NULL); - if (!g_regex_match_full (r, result, strlen (result), 0, 0, &match_info, error)) { - g_prefix_error (error, "Could not parse ^SYSINFO results: "); + if (!g_regex_match_full (r, result, strlen (result), 0, 0, &match_info, &inner_error)) { + if (inner_error) { + g_propagate_error (error, inner_error); + g_prefix_error (error, "Could not parse ^SYSINFO results: "); + } else { + g_set_error_literal (error, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't match ^SYSINFO reply"); + } + + if (match_info) + g_match_info_unref (match_info); g_regex_unref (r); return FALSE; }