From 64c567ad9e4564e9368bc0e0e2b999586435881f Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 3 Aug 2019 11:45:29 +1000 Subject: [PATCH] Fix array bounds error in diff_path If elcnt is zero, we shouldn't even look at list[0]. Signed-off-by: NeilBrown --- diff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diff.c b/diff.c index 3d16e67..1deea20 100644 --- 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); -- 2.39.5