summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-01-08 11:09:22 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-01-08 11:09:22 +0000
commit5357d4177b6823683997a5326ec84bd65389f26a (patch)
tree425f4c840a98099f5e08ee77608e21915e20f1f7 /lib/libc/gen
parent348887c5bf9d94cc44cd83c6517eb5cf2ea3209a (diff)
when malloc fails set bufsize to 0 or all other calls to getmntinfo will fail
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/getmntinfo.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c
index 2d22f2fd424..ebdbfaa9d25 100644
--- a/lib/libc/gen/getmntinfo.c
+++ b/lib/libc/gen/getmntinfo.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getmntinfo.c,v 1.2 1996/08/19 08:23:45 tholo Exp $";
+static char rcsid[] = "$OpenBSD: getmntinfo.c,v 1.3 1999/01/08 11:09:21 art Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -60,8 +60,10 @@ getmntinfo(mntbufp, flags)
if (mntbuf)
free(mntbuf);
bufsize = (mntsize + 1) * sizeof(struct statfs);
- if ((mntbuf = (struct statfs *)malloc(bufsize)) == 0)
+ if ((mntbuf = (struct statfs *)malloc(bufsize)) == 0) {
+ bufsize = 0;
return (0);
+ }
if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0)
return (0);
}