From 09eefa9f988a3d5ab04ad5722982447d7a7d3c97 Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 24 Aug 2016 18:35:12 +0000 Subject: [PATCH] set the error indicator on malloc(3) failure; from Andrey Chernov ; OK millert@ --- lib/libc/stdio/fgetwln.c | 6 ++++-- 1 file 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; -- 2.20.1