[gimp] libgimpbase: strengthen other use of g_win32_locale_filename_from_utf8()



commit 070bcb89799ed12270357f15e9aaf5c2905218f9
Author: Jehan <jehan girinstud io>
Date:   Mon Apr 30 22:14:51 2018 +0200

    libgimpbase: strengthen other use of g_win32_locale_filename_from_utf8()
    
    Let's make our various usages of this broken function more robust, or at
    least return with errors when we can. But this is still seriously
    broken. Inside gimp_locale_directory() though, there was nothing I could
    do, so I just added a FIXME for at least keeping an eye on it.

 libgimpbase/gimpenv.c      |    6 ++++++
 libgimpbase/gimpmetadata.c |   10 ++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index a8bc641..28bbafe 100644
--- a/libgimpbase/gimpenv.c
+++ b/libgimpbase/gimpenv.c
@@ -526,6 +526,12 @@ gimp_locale_directory (void)
       g_free (tmp);
 
 #ifdef G_OS_WIN32
+      /* FIXME: g_win32_locale_filename_from_utf8() can actually return
+       * NULL (we had actual cases of this). Not sure exactly what
+       * gimp_locale_directory() should do when this happens. Anyway
+       * that's really broken, and something should be done some day
+       * about this!
+       */
       tmp = g_win32_locale_filename_from_utf8 (gimp_locale_dir);
       g_free (gimp_locale_dir);
       gimp_locale_dir = tmp;
diff --git a/libgimpbase/gimpmetadata.c b/libgimpbase/gimpmetadata.c
index 69ef4f6..88d7121 100644
--- a/libgimpbase/gimpmetadata.c
+++ b/libgimpbase/gimpmetadata.c
@@ -919,6 +919,16 @@ gimp_metadata_save_to_file (GimpMetadata  *metadata,
 
 #ifdef G_OS_WIN32
   filename = g_win32_locale_filename_from_utf8 (path);
+  /* FIXME!
+   * This call can return NULL.
+   */
+  if (! filename)
+    {
+      g_free (path);
+      g_set_error (error, GIMP_METADATA_ERROR, 0,
+                   _("Conversion of the filename to system codepage failed."));
+      return FALSE;
+    }
 #else
   filename = g_strdup (path);
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]