mirror of git://sourceware.org/git/glibc.git
libio: Flush-only _IO_str_overflow must not return EOF (bug 28949)
In general, _IO_str_overflow returns the character passed as an argument on success. However, if flush-only operation is requested by passing EOF, returning EOF looks like an error, and the caller cannot tell whether the operation was successful or not. _IO_wstr_overflow had the same bug regarding WEOF. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
6fece2968a
commit
88ed43ff0c
|
@ -133,7 +133,10 @@ _IO_str_overflow (FILE *fp, int c)
|
|||
*fp->_IO_write_ptr++ = (unsigned char) c;
|
||||
if (fp->_IO_write_ptr > fp->_IO_read_end)
|
||||
fp->_IO_read_end = fp->_IO_write_ptr;
|
||||
return c;
|
||||
if (flush_only)
|
||||
return 0;
|
||||
else
|
||||
return c;
|
||||
}
|
||||
libc_hidden_def (_IO_str_overflow)
|
||||
|
||||
|
|
|
@ -130,7 +130,10 @@ _IO_wstr_overflow (FILE *fp, wint_t c)
|
|||
*fp->_wide_data->_IO_write_ptr++ = c;
|
||||
if (fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_read_end)
|
||||
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_write_ptr;
|
||||
return c;
|
||||
if (flush_only)
|
||||
return 0;
|
||||
else
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue