[Xfce4-commits] <xfce4-weather-plugin:master> Fix crashes when icon directory does not exist.

Harald Judt noreply at xfce.org
Tue Nov 27 18:40:01 CET 2012


Updating branch refs/heads/master
         to d3ccfcfff7b0682944a11f56d1a86a6794a9a8d3 (commit)
       from 3ecec681c75275c032d1a147ec087ff0f8cffdbf (commit)

commit d3ccfcfff7b0682944a11f56d1a86a6794a9a8d3
Author: Harald Judt <h.judt at gmx.at>
Date:   Tue Nov 27 18:38:32 2012 +0100

    Fix crashes when icon directory does not exist.
    
    Checking for the icon directory was fine but doesn't help if we don't
    verify the results we get are not NULL.

 panel-plugin/weather-icon.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/panel-plugin/weather-icon.c b/panel-plugin/weather-icon.c
index 2226f76..bf3ff61 100644
--- a/panel-plugin/weather-icon.c
+++ b/panel-plugin/weather-icon.c
@@ -242,9 +242,9 @@ find_themes_in_dir(const gchar *path)
             }
         }
         g_dir_close(dir);
+        weather_debug("Found %d icon theme(s) in %s.", themes->len, path);
     } else
         weather_debug("Could not list directory %s.", path);
-    weather_debug("Found %d icon theme(s) in %s.", themes->len, path);
     return themes;
 }
 
@@ -266,17 +266,20 @@ find_icon_themes(void)
                       "xfce4", G_DIR_SEPARATOR_S, "weather",
                       G_DIR_SEPARATOR_S, "icons", NULL);
     found = find_themes_in_dir(dir);
-
     g_free(dir);
-    if (found->len > 0)
-        themes = g_array_append_vals(themes, found->data, found->len);
-    g_array_free(found, FALSE);
+    if (found) {
+        if (found->len > 0)
+            themes = g_array_append_vals(themes, found->data, found->len);
+        g_array_free(found, FALSE);
+    }
 
     /* next find themes in system directory */
     found = find_themes_in_dir(THEMESDIR);
-    if (found->len > 0)
-        themes = g_array_append_vals(themes, found->data, found->len);
-    g_array_free(found, FALSE);
+    if (found) {
+        if (found->len > 0)
+            themes = g_array_append_vals(themes, found->data, found->len);
+        g_array_free(found, FALSE);
+    }
 
     weather_debug("Found %d icon themes in total.", themes->len, dir);
     return themes;


More information about the Xfce4-commits mailing list