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>
Backport from trunk:

View File

@ -240,11 +240,16 @@ g_utf8_collate_key (const gchar *str,
str_norm = g_utf8_normalize (str, len, G_NORMALIZE_ALL_COMPOSE);
result = NULL;
if (g_get_charset (&charset))
{
xfrm_len = strxfrm (NULL, str_norm, 0);
result = g_malloc (xfrm_len + 1);
strxfrm (result, str_norm, xfrm_len + 1);
if (xfrm_len >= 0 && xfrm_len < G_MAXINT - 2)
{
result = g_malloc (xfrm_len + 1);
strxfrm (result, str_norm, xfrm_len + 1);
}
}
else
{
@ -267,14 +272,15 @@ g_utf8_collate_key (const gchar *str,
g_free (str_locale);
}
else
{
xfrm_len = strlen (str_norm);
result = g_malloc (xfrm_len + 2);
result[0] = 'B';
memcpy (result + 1, str_norm, xfrm_len);
result[xfrm_len+1] = '\0';
}
}
if (!result)
{
xfrm_len = strlen (str_norm);
result = g_malloc (xfrm_len + 2);
result[0] = 'B';
memcpy (result + 1, str_norm, xfrm_len);
result[xfrm_len+1] = '\0';
}
g_free (str_norm);