From ed0b773cb9d2f91d93e2e085b7ffaa81c502df50 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sat, 1 Apr 2023 15:44:46 +0200 Subject: [PATCH] [skip ci] Avoid infinite loop in differ TBH I don't understand why this can happen here but not in sebastian/diff. I'll have to take a closer look. --- run-tests.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-tests.php b/run-tests.php index 57486b1d073..0b7d88877db 100755 --- a/run-tests.php +++ b/run-tests.php @@ -3982,11 +3982,11 @@ final class Differ reset($to); foreach ($common as $token) { - while (!($this->isEqual)(reset($from), $token)) { + while (!empty($from) && !($this->isEqual)(reset($from), $token)) { $diff[] = [array_shift($from), self::REMOVED, $fromLine++]; } - while (!($this->isEqual)($token, reset($to))) { + while (!empty($to) && !($this->isEqual)($token, reset($to))) { $diff[] = [array_shift($to), self::ADDED, $toLine++]; }