diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2013-07-31 04:15:41 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-08-05 11:54:32 -0700 |
commit | 63828b844d17d66d18c19375c559ab8678693f97 (patch) | |
tree | a7b4bf873403ab35a64ca165d5894dcc98168d77 /line-log.c | |
parent | 449f5c751c22a12de48c273395540a42460795eb (diff) | |
download | git-63828b844d17d66d18c19375c559ab8678693f97.tar.gz |
log: fix -L bounds checking bug
When 12da1d1f added -L support to git-log, a broken bounds check was
copied from git-blame -L which incorrectly allows -LX to extend one line
past end of file without reporting an error. Instead, it generates an
empty range. Fix this bug.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'line-log.c')
-rw-r--r-- | line-log.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/line-log.c b/line-log.c index c2d01dccc2..1c3ac8dccd 100644 --- a/line-log.c +++ b/line-log.c @@ -594,13 +594,13 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args) lines, &begin, &end, full_name)) die("malformed -L argument '%s'", range_part); + if (lines < end || ((lines || begin) && lines < begin)) + die("file %s has only %lu lines", name_part, lines); if (begin < 1) begin = 1; if (end < 1) end = lines; begin--; - if (lines < end || lines < begin) - die("file %s has only %ld lines", name_part, lines); line_log_data_insert(&ranges, full_name, begin, end); free_filespec(spec); |