From 5a383a31b2862f9ecface4a3a6fc3235754acb8f Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Tue, 10 Mar 2009 08:33:52 +0000 Subject: [PATCH] * Fixes NB#104978, crash in account wizard when language/region do not match pmo-trunk-r7907 --- src/hildon2/modest-country-picker.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hildon2/modest-country-picker.c b/src/hildon2/modest-country-picker.c index a05fcf8..8309f92 100644 --- a/src/hildon2/modest-country-picker.c +++ b/src/hildon2/modest-country-picker.c @@ -169,9 +169,13 @@ parse_mcc_mapping_line (const char* line, char** country) tab = g_utf8_strrchr (line, -1, '\t'); *country = g_utf8_find_next_char (tab, NULL); - /* Replace by end of string */ - final = g_utf8_strrchr (tab, g_utf8_strlen (tab, 100) + 1, '\n'); - *final = '\0'; + /* Replace by end of string. We need to use strlen, because + g_utf8_strrchr expects bytes and not UTF8 characters */ + final = g_utf8_strrchr (tab, strlen (tab) + 1, '\n'); + if (G_LIKELY (final)) + *final = '\0'; + else + tab[strlen(tab) - 1] = '\0'; /* Get MCC code */ mcc[0] = g_utf8_get_char (line); -- 1.7.9.5