Fixed obscure bug in setvbuf
This commit is contained in:
parent
42b693b1af
commit
ca09a9b0e8
@ -23,8 +23,9 @@ setvbuf(register FILE *stream, char *buf, int mode, size_t size)
|
|||||||
|
|
||||||
stream->_flags &= ~(_IOMYBUF | _IONBF | _IOLBF);
|
stream->_flags &= ~(_IOMYBUF | _IONBF | _IOLBF);
|
||||||
|
|
||||||
|
if (buf && size <= 0) retval = EOF;
|
||||||
if (!buf && (mode != _IONBF)) {
|
if (!buf && (mode != _IONBF)) {
|
||||||
if ((buf = (char *) malloc(size)) == NULL) {
|
if (size <= 0 || (buf = (char *) malloc(size)) == NULL) {
|
||||||
retval = EOF;
|
retval = EOF;
|
||||||
} else {
|
} else {
|
||||||
stream->_flags |= _IOMYBUF;
|
stream->_flags |= _IOMYBUF;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user