Fixed obscure bug in setvbuf

This commit is contained in:
ceriel 1995-12-04 17:11:54 +00:00
parent 6d39052c12
commit 812b6f2158

View file

@ -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;