Handle strfxrm returning -1 a little better. Problem pointed out by Takao

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


svn path=/trunk/; revision=7015
This commit is contained in:
Matthias Clasen 2008-06-11 19:38:35 +00:00
parent f532b61fea
commit de09a5803a
2 changed files with 24 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2008-06-11 Matthias Clasen <mclasen@redhat.com>
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-11 Matthias Clasen <mclasen@redhat.com> 2008-06-11 Matthias Clasen <mclasen@redhat.com>
Bug 529321 make check fails in glib/pcre Bug 529321 make check fails in glib/pcre

View File

@ -414,11 +414,16 @@ 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);
result = g_malloc (xfrm_len + 1); if (xfrm_len >= 0 && xfrm_len < G_MAXINT - 2)
strxfrm (result, str_norm, xfrm_len + 1); {
result = g_malloc (xfrm_len + 1);
strxfrm (result, str_norm, xfrm_len + 1);
}
} }
else else
{ {
@ -441,14 +446,15 @@ g_utf8_collate_key (const gchar *str,
g_free (str_locale); g_free (str_locale);
} }
else }
{
xfrm_len = strlen (str_norm); if (!result)
result = g_malloc (xfrm_len + 2); {
result[0] = 'B'; xfrm_len = strlen (str_norm);
memcpy (result + 1, str_norm, xfrm_len); result = g_malloc (xfrm_len + 2);
result[xfrm_len+1] = '\0'; result[0] = 'B';
} memcpy (result + 1, str_norm, xfrm_len);
result[xfrm_len+1] = '\0';
} }
g_free (str_norm); g_free (str_norm);