grep: handle corrupt index files early
[gitweb.git] / apply.c
diff --git a/apply.c b/apply.c
index d4c1dd7efd3422ec8f6a08ecaae29dee15d775d7..d3dc1b292b9ecc38ed6c257a063a86daa7c98d66 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -2958,6 +2958,8 @@ static int apply_one_fragment(struct apply_state *state,
            newlines.len > 0 && newlines.buf[newlines.len - 1] == '\n') {
                old--;
                strbuf_setlen(&newlines, newlines.len - 1);
+               preimage.line_allocated[preimage.nr - 1].len--;
+               postimage.line_allocated[postimage.nr - 1].len--;
        }
 
        leading = frag->leading;