Bug 314453 – Nautilus crashes in Solaris when browsing the attached

file

        * glib/gunicollate.c (g_utf8_collate_key): Handle strfxrm returning
        -1 a little better. Problem pointed out by Takao Fujiwara



svn path=/branches/glib-2-16/; revision=7114
This commit is contained in:
Matthias Clasen 2008-06-30 22:37:45 +00:00
parent 3602dcca46
commit 281f4c58bf
2 changed files with 26 additions and 10 deletions

View File

@ -1,3 +1,13 @@
2008-06-30 Matthias Clasen <mclasen@redhat.com>
Backport from trunk:
Bug 314453 Nautilus crashes in Solaris when browsing the attached
file
* glib/gunicollate.c (g_utf8_collate_key): Handle strfxrm returning
-1 a little better. Problem pointed out by Takao Fujiwara
2008-06-30 Matthias Clasen <mclasen@redhat.com> 2008-06-30 Matthias Clasen <mclasen@redhat.com>
Backport from trunk: Backport from trunk:

View File

@ -240,12 +240,17 @@ g_utf8_collate_key (const gchar *str,
str_norm = g_utf8_normalize (str, len, G_NORMALIZE_ALL_COMPOSE); str_norm = g_utf8_normalize (str, len, G_NORMALIZE_ALL_COMPOSE);
result = NULL;
if (g_get_charset (&charset)) if (g_get_charset (&charset))
{ {
xfrm_len = strxfrm (NULL, str_norm, 0); xfrm_len = strxfrm (NULL, str_norm, 0);
if (xfrm_len >= 0 && xfrm_len < G_MAXINT - 2)
{
result = g_malloc (xfrm_len + 1); result = g_malloc (xfrm_len + 1);
strxfrm (result, str_norm, xfrm_len + 1); strxfrm (result, str_norm, xfrm_len + 1);
} }
}
else else
{ {
gchar *str_locale = g_convert (str_norm, -1, charset, "UTF-8", NULL, NULL, NULL); gchar *str_locale = g_convert (str_norm, -1, charset, "UTF-8", NULL, NULL, NULL);
@ -267,7 +272,9 @@ g_utf8_collate_key (const gchar *str,
g_free (str_locale); g_free (str_locale);
} }
else }
if (!result)
{ {
xfrm_len = strlen (str_norm); xfrm_len = strlen (str_norm);
result = g_malloc (xfrm_len + 2); result = g_malloc (xfrm_len + 2);
@ -275,7 +282,6 @@ g_utf8_collate_key (const gchar *str,
memcpy (result + 1, str_norm, xfrm_len); memcpy (result + 1, str_norm, xfrm_len);
result[xfrm_len+1] = '\0'; result[xfrm_len+1] = '\0';
} }
}
g_free (str_norm); g_free (str_norm);
#endif /* __STDC_ISO_10646__ */ #endif /* __STDC_ISO_10646__ */