--- includes/file.inc	2008-08-13 19:59:09.000000000 -0400
+++ includes/file-scan_dir.inc	2008-08-26 15:08:42.000000000 -0400
@@ -641,7 +641,7 @@ function file_scan_directory($dir, $mask
   $files = array();
 
   if (is_dir($dir) && $handle = opendir($dir)) {
-    while ($file = readdir($handle)) {
+    while (false !== ($file = readdir($handle))) {
       if (!in_array($file, $nomask) && $file[0] != '.') {
         if (is_dir("$dir/$file") && $recurse) {
           $files = array_merge($files, file_scan_directory("$dir/$file", $mask, $nomask, $callback, $recurse, $key, $min_depth, $depth + 1));
