e9cb68
diff -ur xfdesktop-4.10.3.org/common/xfdesktop-common.c xfdesktop-4.10.3/common/xfdesktop-common.c
e9cb68
--- xfdesktop-4.10.3.org/common/xfdesktop-common.c	2014-11-16 07:20:57.000000000 +0100
e9cb68
+++ xfdesktop-4.10.3/common/xfdesktop-common.c	2014-12-11 08:58:23.511865532 +0100
e9cb68
@@ -102,26 +102,38 @@
e9cb68
     items = 0;
e9cb68
     files = g_strsplit(contents, "\n", -1);
e9cb68
 
e9cb68
+    g_free(contents); /* not needed anymore */
e9cb68
+
e9cb68
     /* Since the first line is the file identifier, we need to skip it.
e9cb68
      * Additionally, we want to skip blank lines. */
e9cb68
-    for(i = 1; files[i] != NULL; i++) {
e9cb68
-        if(g_strcmp0(files[i], "") != 0) {
e9cb68
-            g_free(files[items]);
e9cb68
-            files[items] = g_strdup(files[i]);
e9cb68
-            DBG("files[items] %s", files[items]);
e9cb68
-            items++;
e9cb68
+
e9cb68
+     /* a file with just the header will have only one line */
e9cb68
+
e9cb68
+    if(files[0] != NULL)
e9cb68
+    {
e9cb68
+        g_free(files[0]);   /* that's the only non-empty line we need to remove */
e9cb68
+        files[0] = NULL;
e9cb68
+        for(i = 1; files[i] != NULL; i++) {
e9cb68
+            if(g_strcmp0(files[i], "") != 0) {
e9cb68
+                files[items]=files[i];  /* move the string to the current item slot */
e9cb68
+
e9cb68
+                items++;
e9cb68
+            } else { 
e9cb68
+                g_free(files[i]);   /* free the irrelevant empty string */
e9cb68
+            }
e9cb68
         }
e9cb68
+        files[items] = NULL; /* set the sentinel */
e9cb68
+
e9cb68
+        /* resize */
e9cb68
+        
e9cb68
+        files = g_realloc(files, sizeof(gchar *) * (items+1));
e9cb68
     }
e9cb68
-    files[items+1] = NULL;
e9cb68
 
e9cb68
-    files = g_realloc(files, sizeof(gchar *) * (items+1));
e9cb68
 
e9cb68
     DBG("items %d", items);
e9cb68
     if(n_items)
e9cb68
         *n_items = items;
e9cb68
 
e9cb68
-    g_free(contents);
e9cb68
-
e9cb68
     return files;
e9cb68
 }
e9cb68