Fix re-initialization of FILE flags and mbstate in freopen

* libc/stdio/freopen.c (_freopen_r): Only reset __SWID bit per SUSv4.
        * libc/stdio64/freopen64.c (_freopen64_r): Add missing resetting of
        flag values and _mbstate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2015-12-08 18:44:23 +01:00
parent 6c3a5d263f
commit 414e794811
3 changed files with 10 additions and 1 deletions

View File

@ -208,6 +208,9 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
if (HASLB (fp))
FREELB (ptr, fp);
fp->_lb._size = 0;
fp->_flags &= ~__SORD;
fp->_flags2 &= ~__SWID;
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
if (f < 0)
{ /* did not get it after all */