diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 0ffae22ec316979730836f4f3dbe644e95b5512e..2d76b685018fec0f690b154672ae0f5c149774bd 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -7,7 +7,7 @@ OCP\JSON::checkLoggedIn();
 $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
 $dir = \OC\Files\Filesystem::normalizePath($dir);
 $dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
-if (!$dirInfo->getType() === 'dir') {
+if (!$dirInfo || !$dirInfo->getType() === 'dir') {
 	header("HTTP/1.0 404 Not Found");
 	exit();
 }