From 5357d4177b6823683997a5326ec84bd65389f26a Mon Sep 17 00:00:00 2001 From: Artur Grabowski Date: Fri, 8 Jan 1999 11:09:22 +0000 Subject: when malloc fails set bufsize to 0 or all other calls to getmntinfo will fail --- lib/libc/gen/getmntinfo.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc/gen') 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 @@ -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); } -- cgit v1.2.3