diff options
author | 1999-01-08 11:09:21 +0000 | |
---|---|---|
committer | 1999-01-08 11:09:21 +0000 | |
commit | 558116bf51d439ca01db4a006abc7a7b2bf94ee8 (patch) | |
tree | 8477c7699a6764b2ae304d0fddfe39334463f086 | |
parent | always initialize error in inactive (diff) | |
download | wireguard-openbsd-558116bf51d439ca01db4a006abc7a7b2bf94ee8.tar.xz wireguard-openbsd-558116bf51d439ca01db4a006abc7a7b2bf94ee8.zip |
when malloc fails set bufsize to 0 or all other calls to getmntinfo will fail
-rw-r--r-- | lib/libc/gen/getmntinfo.c | 6 |
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); } |