]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check directory handle before we use it
authorRobin Appelman <icewind@owncloud.com>
Mon, 9 Feb 2015 11:36:18 +0000 (12:36 +0100)
committerRobin Appelman <icewind@owncloud.com>
Mon, 9 Feb 2015 11:36:18 +0000 (12:36 +0100)
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;
+                                       }
                                }
                        }
                }