From 812b6f2158ec0b0f326d340f59a210fc65838525 Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 4 Dec 1995 17:11:54 +0000 Subject: [PATCH] Fixed obscure bug in setvbuf --- lang/cem/libcc.ansi/stdio/setvbuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lang/cem/libcc.ansi/stdio/setvbuf.c b/lang/cem/libcc.ansi/stdio/setvbuf.c index 3e6366bee..c6dd3dc46 100644 --- a/lang/cem/libcc.ansi/stdio/setvbuf.c +++ b/lang/cem/libcc.ansi/stdio/setvbuf.c @@ -23,8 +23,9 @@ setvbuf(register FILE *stream, char *buf, int mode, size_t size) stream->_flags &= ~(_IOMYBUF | _IONBF | _IOLBF); + if (buf && size <= 0) retval = EOF; if (!buf && (mode != _IONBF)) { - if ((buf = (char *) malloc(size)) == NULL) { + if (size <= 0 || (buf = (char *) malloc(size)) == NULL) { retval = EOF; } else { stream->_flags |= _IOMYBUF;