]> git.neil.brown.name Git - wiggle.git/commitdiff
Fix array bounds error in diff_path
authorNeilBrown <neilb@suse.de>
Sat, 3 Aug 2019 01:45:29 +0000 (11:45 +1000)
committerNeilBrown <neilb@suse.de>
Sat, 3 Aug 2019 01:45:29 +0000 (11:45 +1000)
If elcnt is zero, we shouldn't even look at list[0].

Signed-off-by: NeilBrown <neilb@suse.de>
diff.c

diff --git a/diff.c b/diff.c
index 3d16e6778bfa1f7df22504d3c1bcafaec83fc702..1deea20941f3ae3391d5100da29bc640fb2047dd 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -614,7 +614,8 @@ struct csl *diff_patch(struct file a, struct file b)
 {
        int ap, bp;
        struct csl *csl = NULL;
-       if (a.list[0].start[0] != '\0' ||
+       if (a.elcnt == 0 || b.elcnt == 0 ||
+           a.list[0].start[0] != '\0' ||
            b.list[0].start[0] != '\0')
                /* this is not a patch */
                return diff(a, b);