[Xfce4-commits] [apps/ristretto] 01/01: Check if file name is a valid utf8 string to avoid crashes

noreply at xfce.org noreply at xfce.org
Wed Oct 5 11:54:40 CEST 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/ristretto.

commit 7ea13b74dfc95b86650d79e6c373799f649de1d7
Author: Igor <f2404 at yandex.ru>
Date:   Wed Oct 5 12:53:55 2016 +0300

    Check if file name is a valid utf8 string to avoid crashes
    
    Fixes https://bugzilla.xfce.org/show_bug.cgi?id=12445
---
 src/file.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/file.c b/src/file.c
index a17dc4f..648ce6a 100644
--- a/src/file.c
+++ b/src/file.c
@@ -371,17 +371,24 @@ rstto_file_get_collate_key ( RsttoFile *r_file )
         gchar *basename = g_file_get_basename (rstto_file_get_file (r_file));
         if ( NULL != basename )
         {
-            /* If we can use casefold for case insenstivie sorting, then
-             * do so */
-            gchar *casefold = g_utf8_casefold (basename, -1);
-            if ( NULL != casefold )
+            if ( g_utf8_validate (basename, -1, NULL) )
             {
-                r_file->priv->collate_key = g_utf8_collate_key_for_filename (casefold, -1);
-                g_free (casefold);
+                /* If we can use casefold for case insenstivie sorting, then
+                 * do so */
+                gchar *casefold = g_utf8_casefold (basename, -1);
+                if ( NULL != casefold )
+                {
+                    r_file->priv->collate_key = g_utf8_collate_key_for_filename (casefold, -1);
+                    g_free (casefold);
+                }
+                else
+                {
+                    r_file->priv->collate_key = g_utf8_collate_key_for_filename (basename, -1);
+                }
             }
             else
             {
-                r_file->priv->collate_key = g_utf8_collate_key_for_filename (basename, -1);
+                r_file->priv->collate_key = g_strdup (basename);
             }
             g_free (basename);
         }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list