diff --git a/grep.c b/grep.c index ac34bfeafb..2f8b9553df 100644 --- a/grep.c +++ b/grep.c @@ -1735,7 +1735,8 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle peek_eol = end_of_line(peek_bol, &peek_left); } - if (match_funcname(opt, gs, peek_bol, peek_eol)) + if (peek_bol >= gs->buf + gs->size || + match_funcname(opt, gs, peek_bol, peek_eol)) show_function = 0; } if (show_function || diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 875dcfd98f..af2cf2f78a 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -31,6 +31,7 @@ int main(int argc, const char **argv) return 0; /* char ?? */ } + EOF test_expect_success setup '