summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2016-08-24 18:35:12 +0000
committerschwarze <schwarze@openbsd.org>2016-08-24 18:35:12 +0000
commit09eefa9f988a3d5ab04ad5722982447d7a7d3c97 (patch)
tree79d22efe47b29bbd070404c78ac2821753d98730 /lib/libc
parentSince the removal of rwhod and friends a couple of years ago, there (diff)
downloadwireguard-openbsd-09eefa9f988a3d5ab04ad5722982447d7a7d3c97.tar.xz
wireguard-openbsd-09eefa9f988a3d5ab04ad5722982447d7a7d3c97.zip
set the error indicator on malloc(3) failure;
from Andrey Chernov <ache at freebsd dot org>; OK millert@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdio/fgetwln.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c
index 37fcf3a1aee..2ee7e8d61e6 100644
--- a/lib/libc/stdio/fgetwln.c
+++ b/lib/libc/stdio/fgetwln.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fgetwln.c,v 1.2 2016/08/21 21:10:52 schwarze Exp $ */
+/* $OpenBSD: fgetwln.c,v 1.3 2016/08/24 18:35:12 schwarze Exp $ */
/*-
* Copyright (c) 2002-2004 Tim J. Robbins.
@@ -61,8 +61,10 @@ fgetwln(FILE * __restrict fp, size_t *lenp)
while ((wc = __fgetwc_unlock(fp)) != WEOF) {
#define GROW 512
if (len >= fp->_lb._size / sizeof(wchar_t) &&
- __slbexpand(fp, len + GROW))
+ __slbexpand(fp, len + GROW)) {
+ fp->_flags |= __SERR;
goto error;
+ }
*((wchar_t *)fp->_lb._base + len++) = wc;
if (wc == L'\n')
break;