[gdk-pixbuf] queryloaders: strdup moduledir



commit 971b09fcd8f1ff5e1c4df0772feab2371bbcdced
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Fri Jan 5 16:46:58 2018 +0100

    queryloaders: strdup moduledir
    
    Needed for a follow up patch which will fix a memory leak on the
    windows code path

 gdk-pixbuf/queryloaders.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c
index 0fb40fd..085ef7c 100644
--- a/gdk-pixbuf/queryloaders.c
+++ b/gdk-pixbuf/queryloaders.c
@@ -338,17 +338,19 @@ int main (int argc, char **argv)
 
         if (argc == first_file) {
 #ifdef USE_GMODULE
-                const char *moduledir;
+                char *moduledir;
                 GDir *dir;
                 GList *l, *modules;
 
-                moduledir = g_getenv ("GDK_PIXBUF_MODULEDIR");
+                moduledir = g_strdup (g_getenv ("GDK_PIXBUF_MODULEDIR"));
 #ifdef G_OS_WIN32
                 if (moduledir != NULL && *moduledir != '\0')
                         moduledir = g_locale_to_utf8 (moduledir, -1, NULL, NULL, NULL);
 #endif
-                if (moduledir == NULL || *moduledir == '\0')
-                        moduledir = PIXBUF_LIBDIR;
+                if (moduledir == NULL || *moduledir == '\0') {
+                        g_free (moduledir);
+                        moduledir = g_strdup (PIXBUF_LIBDIR);
+                }
 
                 g_string_append_printf (contents, "# LoaderDir = %s\n#\n", moduledir);
 
@@ -371,6 +373,7 @@ int main (int argc, char **argv)
                 for (l = modules; l != NULL; l = l->next)
                         query_module (contents, moduledir, l->data);
                 g_list_free_full (modules, g_free);
+                g_free (moduledir);
 #else
                 g_string_append_printf (contents, "# dynamic loading of modules not supported\n");
 #endif


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