]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check directory handle before we use it
authorRobin McCorkell <rmccorkell@karoshi.org.uk>
Sun, 15 Mar 2015 18:28:01 +0000 (18:28 +0000)
committerRobin McCorkell <rmccorkell@karoshi.org.uk>
Sun, 15 Mar 2015 18:28:01 +0000 (18:28 +0000)
lib/private/tempmanager.php

index a3bb07f9d63f21823bfbcf851da6b69499bd6264..60b9c9dc0d45767f3853910d85b4f0dd9f1d85e3 100644 (file)
@@ -132,12 +132,14 @@ class TempManager implements ITempManager {
                $cutOfTime = time() - 3600;
                $files = array();
                $dh = opendir($this->tmpBaseDir);
-               while (($file = readdir($dh)) !== false) {
-                       if (substr($file, 0, 7) === 'oc_tmp_') {
-                               $path = $this->tmpBaseDir . '/' . $file;
-                               $mtime = filemtime($path);
-                               if ($mtime < $cutOfTime) {
-                                       $files[] = $path;
+               if ($dh) {
+                       while (($file = readdir($dh)) !== false) {
+                               if (substr($file, 0, 7) === 'oc_tmp_') {
+                                       $path = $this->tmpBaseDir . '/' . $file;
+                                       $mtime = filemtime($path);
+                                       if ($mtime < $cutOfTime) {
+                                               $files[] = $path;
+                                       }
                                }
                        }
                }