]> git.neil.brown.name Git - wiggle.git/commitdiff
split_stream: guard against body being NULL.
authorNeilBrown <neil@brown.name>
Fri, 27 Dec 2019 04:54:46 +0000 (15:54 +1100)
committerNeilBrown <neil@brown.name>
Fri, 27 Dec 2019 04:54:46 +0000 (15:54 +1100)
If body is NULL, adding 'len' to it makes no sense.
Just abort early in that case.

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

diff --git a/split.c b/split.c
index 367a590face26dc48fab0af6da030ac0d388e133..27f9b7e7acb573dc4bbe3d4b269fe7263f7721a1 100644 (file)
--- a/split.c
+++ b/split.c
@@ -125,9 +125,13 @@ struct file split_stream(struct stream s, int type)
 {
        int cnt;
        struct file f;
-
        char *c, *end;
 
+       if (!s.body) {
+               f.list = NULL;
+               f.elcnt = 0;
+               return f;
+       }
        end = s.body+s.len;
        c = s.body;