diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2013-07-23 16:28:08 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-23 21:09:48 +0200 |
commit | df6308eb82bc9d2074b35387583548b8b153433d (patch) | |
tree | 4edf2970e95e0dcedb2d2e8b97c44d7ea15b3057 /line-log.c | |
parent | range-set: satisfy non-empty ranges invariant (diff) | |
download | git-df6308eb82bc9d2074b35387583548b8b153433d.tar.xz git-df6308eb82bc9d2074b35387583548b8b153433d.zip |
line-log: fix "log -LN" crash when N is last line of file
range-set invariants are: ranges must be (1) non-empty, (2) disjoint,
(3) sorted in ascending order.
line_log_data_insert() breaks the non-empty invariant under the
following conditions: the incoming range is empty and the pathname
attached to the range has not yet been encountered. In this case,
line_log_data_insert() assigns the empty range to a new line_log_data
record without taking any action to ensure that the empty range is
eventually folded out. Subsequent range-set functions crash or throw an
assertion failure upon encountering such an anomaly. Fix this bug.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Acked-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'line-log.c')
-rw-r--r-- | line-log.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/line-log.c b/line-log.c index 6f94d56063..c2d01dccc2 100644 --- a/line-log.c +++ b/line-log.c @@ -299,6 +299,7 @@ static void line_log_data_insert(struct line_log_data **list, p = xcalloc(1, sizeof(struct line_log_data)); p->path = path; range_set_append(&p->ranges, begin, end); + sort_and_merge_range_set(&p->ranges); if (ip) { p->next = ip->next; ip->next = p; |