]> git.neil.brown.name Git - wiggle.git/commitdiff
vpatch: guard against patch list being empty.
authorNeilBrown <neilb@suse.de>
Fri, 27 Dec 2019 04:45:53 +0000 (15:45 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 27 Dec 2019 04:45:53 +0000 (15:45 +1100)
Mostly and empty list works, but get_prev() can
mess up - so fix it.

Signed-off-by: NeilBrown <neil@brown.name>
vpatch.c

index 9c37562a8160a255ddaf44526f111c46d7cd66af..a1aa0354c30a3296c21213e3c1e61ca0d86a477f 100644 (file)
--- a/vpatch.c
+++ b/vpatch.c
@@ -2427,7 +2427,7 @@ static void calc_one(struct plist *pl, FILE *f, int reverse,
 static int get_prev(int pos, struct plist *pl, int n, int mode)
 {
        int found = 0;
-       if (pos == -1)
+       if (pos == -1 || pl == NULL)
                return pos;
        do {
                if (pl[pos].prev == -1)