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