From 40d2346f296559073578884ba0ba21cc7c28c94f Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 25 Apr 2020 09:16:53 -0700 Subject: [PATCH] Add a missing "null" check when rebuilding old/new diff content Summary: See . This list may include `null` values. Until PHP 7.4, `$x = null; echo $x['y'];` does not emit a warning. Sneaky! Test Plan: - Traced `null` values from `reparseHunksForSpecialAttributes()`, saw them no longer incorporated into corpus bodies. - This has some amount of test coverage. Differential Revision: https://secure.phabricator.com/D21169 --- .../differential/parser/DifferentialHunkParser.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/applications/differential/parser/DifferentialHunkParser.php b/src/applications/differential/parser/DifferentialHunkParser.php index 924789ca83..52f5bb90dc 100644 --- a/src/applications/differential/parser/DifferentialHunkParser.php +++ b/src/applications/differential/parser/DifferentialHunkParser.php @@ -456,6 +456,11 @@ final class DifferentialHunkParser extends Phobject { $corpus = array(); foreach ($lines as $l) { + if ($l === null) { + $corpus[] = "\n"; + continue; + } + if ($l['type'] != '\\') { if ($l['text'] === null) { // There's no text on this side of the diff, but insert a placeholder