patch: fix debug log failure
authorAaro Koskinen <aaro.koskinen@iki.fi>
Mon, 21 Nov 2016 22:19:50 +0000 (00:19 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 24 Nov 2016 10:38:56 +0000 (11:38 +0100)
If we reach the end of plist it means the input has still data while we
are expecting EOF. Fix the log to avoid a crash.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/patch.c

index 988021d776609f22f33baf566ac2f748cb37a44c..4ee9339a7ee762d760eb9f507712a3f3758103ee 100644 (file)
@@ -295,7 +295,7 @@ static int apply_one_hunk(void)
                                // recheck remaining buffered data for a new match.
 
                                if (PATCH_DEBUG)
-                                       fdprintf(2, "NOT: %s\n", plist->data);
+                                       fdprintf(2, "NOT: %s\n", plist ? plist->data : "EOF");
 
                                TT.state = 3;
                                check = buf;