Fix crash in fwide():
* _IO_USER_BUF was being used to indicate a user-owned buffer without taking into account that there are two of those: one for the normal and another one for the wide version of a stream. Backport _IO_FLAGS2_USER_WBUF from current glibc version to fix that.
This commit is contained in:
parent
b3482508b4
commit
0d03f689b2
@ -139,6 +139,7 @@
|
||||
#define _IO_USER_LOCK 0x8000
|
||||
|
||||
#define _IO_FLAGS2_MMAP 1
|
||||
#define _IO_FLAGS2_USER_WBUF 8
|
||||
|
||||
/* These are "formatting flags" matching the iostream fmtflags enum values. */
|
||||
#define _IO_SKIPWS 01
|
||||
|
@ -115,14 +115,14 @@ _IO_wsetb (f, b, eb, a)
|
||||
wchar_t *eb;
|
||||
int a;
|
||||
{
|
||||
if (f->_wide_data->_IO_buf_base && !(f->_flags & _IO_USER_BUF))
|
||||
FREE_BUF (f->_wide_data->_IO_buf_base, _IO_wblen (f));
|
||||
if (f->_wide_data->_IO_buf_base && !(f->_flags2 & _IO_FLAGS2_USER_WBUF))
|
||||
FREE_BUF (f->_wide_data->_IO_buf_base, _IO_wblen (f));
|
||||
f->_wide_data->_IO_buf_base = b;
|
||||
f->_wide_data->_IO_buf_end = eb;
|
||||
if (a)
|
||||
f->_flags &= ~_IO_USER_BUF;
|
||||
f->_flags2 &= ~_IO_FLAGS2_USER_WBUF;
|
||||
else
|
||||
f->_flags |= _IO_USER_BUF;
|
||||
f->_flags2 |= _IO_FLAGS2_USER_WBUF;
|
||||
}
|
||||
INTDEF(_IO_wsetb)
|
||||
|
||||
@ -198,7 +198,7 @@ _IO_wdefault_finish (fp, dummy)
|
||||
int dummy;
|
||||
{
|
||||
struct _IO_marker *mark;
|
||||
if (fp->_wide_data->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
|
||||
if (fp->_wide_data->_IO_buf_base && !(fp->_flags2 & _IO_FLAGS2_USER_WBUF))
|
||||
{
|
||||
FREE_BUF (fp->_wide_data->_IO_buf_base,
|
||||
_IO_wblen (fp) * sizeof (wchar_t));
|
||||
|
Loading…
x
Reference in New Issue
Block a user