From 62f0a8da099237256a168907c456d9673ac98c09 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 16 Jul 2016 11:48:39 +0200 Subject: [PATCH] LOC fix if file is corrupted --- Utils/Git/Repository.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 3f9158b3e..3a92354a6 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -642,10 +642,14 @@ class Repository continue; } - $fh = fopen($path = $this->getDirectoryPath() . ($this->bare ? '/' : '/../') . $line, 'r'); + if(!file_exists($path = $this->getDirectoryPath() . ($this->bare ? '/' : '/../') . $line)) { + return 0; + } + + $fh = fopen($path, 'r'); if (!$fh) { - throw new PathException($path); + return 0; } while (!feof($fh)) { @@ -844,6 +848,7 @@ class Repository throw new \Exception('Invalid commit id'); } + // todo: validate if array values are all initialized $author = explode(':', $lines[1]); $author = explode('<', trim($author[1])); $date = substr($lines[2], 6);