From: Neil Brown Date: Tue, 8 May 2012 10:28:56 +0000 (+1000) Subject: Avoid buffer overflow when checking for hunk header X-Git-Tag: v0.9~28 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=8092e41a444fd45799c14d51c1d0d842bade8ef7;p=wiggle.git Avoid buffer overflow when checking for hunk header Signed-off-by: NeilBrown --- diff --git a/merge2.c b/merge2.c index d87b89c..dc495af 100644 --- a/merge2.c +++ b/merge2.c @@ -347,7 +347,8 @@ struct ci make_merger(struct file af, struct file bf, struct file cf, * align with an end-of-line in 'a', so adjust endpoint */ int newa = csl1[c1].a; - if (bf.list[b].start && bf.list[b].start[0] == '\0') { + if (b < bf.elcnt && bf.list[b].start + && bf.list[b].start[0] == '\0') { while (newa > a && !ends_line(af.list[newa-1])) newa--;