Index: trunk/src/sh_files.c
===================================================================
--- trunk/src/sh_files.c	(revision 564)
+++ trunk/src/sh_files.c	(revision 565)
@@ -2323,7 +2323,12 @@
 	    }
 	  dirlist = addto_sh_dirlist (thisEntry, dirlist);
+#if defined(SH_USE_SCANDIR)
+	  free(entryList[entry]); /* scandir() mallocs entries */
+#endif
 	}
   }
-#if !defined(SH_USE_SCANDIR)  
+#if defined(SH_USE_SCANDIR)
+  free(entryList);
+#else
   while (thisEntry != NULL);
 #endif
