diff --git a/bin/df/df.c b/bin/df/df.c index 77c2d28efe70..f244c26f8767 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -548,8 +548,10 @@ makenetvfslist() } } - if ((str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { - warnx("malloc failed"); + if (cnt == 0 || + (str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { + if (cnt > 0) + warnx("malloc failed"); free(listptr); return (NULL); }