diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index ecaf799fe9b..403189bc92b 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -717,6 +717,8 @@ locate_hunk(LINENUM fuzz) || diff_type == UNI_DIFF)) { say("Empty context always matches.\n"); } + if (first_guess == 0) /* empty file */ + return 1; return (first_guess); } if (max_neg_offset >= first_guess) /* do not try lines < 0 */