39 lines
1.5 KiB
Diff
39 lines
1.5 KiB
Diff
commit 219424a6e2d017491a05ecbed661bccde3f991ef
|
|
Author: Aleksander Morgado <aleksander@lanedo.com>
|
|
Date: Wed Sep 12 07:34:37 2012 +0200
|
|
|
|
gsm: skip additional UTF-8 validity check when parsing operator
|
|
|
|
This is a fix related to the previous e07c2162d.
|
|
|
|
mm_charset_take_and_convert_to_utf8() already does a UTF-8 validity check
|
|
internally before returning the string, so it's pointless to do a new one
|
|
on the returned string.
|
|
|
|
Plus, mm_charset_take_and_convert_to_utf8() may really return NULL, which
|
|
would end up in segfaulting as g_utf8_validate() expects always a non-NULL
|
|
string.
|
|
|
|
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
|
|
index 83e4083..60f2ea1 100644
|
|
--- a/src/mm-generic-gsm.c
|
|
+++ b/src/mm-generic-gsm.c
|
|
@@ -3066,13 +3066,14 @@ parse_operator (const char *reply, MMModemCharset cur_charset)
|
|
* string of the bytes of the operator name as encoded by the current
|
|
* character set.
|
|
*/
|
|
- if (cur_charset == MM_MODEM_CHARSET_UCS2)
|
|
+ if (cur_charset == MM_MODEM_CHARSET_UCS2) {
|
|
+ /* In this case we're already checking UTF-8 validity */
|
|
operator = mm_charset_take_and_convert_to_utf8 (operator, MM_MODEM_CHARSET_UCS2);
|
|
-
|
|
+ }
|
|
/* Ensure the operator name is valid UTF-8 so that we can send it
|
|
* through D-Bus and such.
|
|
*/
|
|
- if (!g_utf8_validate (operator, -1, NULL)) {
|
|
+ else if (!g_utf8_validate (operator, -1, NULL)) {
|
|
g_free (operator);
|
|
operator = NULL;
|
|
}
|