summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-09-12 07:34:37 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-09-12 07:35:11 +0200
commit219424a6e2d017491a05ecbed661bccde3f991ef (patch)
tree26da2cd130c54ff74535267140880aeb8efd1d97
parente07c2162d66ab1a2e938db48744fc00afd29c272 (diff)
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.
-rw-r--r--src/mm-generic-gsm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 83e4083b..60f2ea15 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;
}