set _IOMYBUF in setvbuf() when necessary
This commit is contained in:
parent
0cc8f53eec
commit
0ad960a9b0
1 changed files with 7 additions and 2 deletions
|
@ -23,8 +23,13 @@ setvbuf(register FILE *stream, char *buf, int mode, size_t size)
|
|||
|
||||
stream->_flags &= ~(_IOMYBUF | _IONBF | _IOLBF);
|
||||
|
||||
if (!buf && (mode != _IONBF))
|
||||
if ((buf = (char *) malloc(size)) == NULL) retval = EOF;
|
||||
if (!buf && (mode != _IONBF)) {
|
||||
if ((buf = (char *) malloc(size)) == NULL) {
|
||||
retval = EOF;
|
||||
} else {
|
||||
stream->_flags |= _IOMYBUF;
|
||||
}
|
||||
}
|
||||
|
||||
if (io_testflag(stream, _IOREADING) || io_testflag(stream, _IOWRITING))
|
||||
retval = EOF;
|
||||
|
|
Loading…
Reference in a new issue