From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 0BA6E3858C5F; Mon, 20 Nov 2023 20:02:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BA6E3858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700510521; bh=QkaDAGRFx9rdoQ9WUJ6SJSnQiPSqfeXxFe9tnRhSyTg=; h=From:To:Subject:Date:From; b=X/Gh1zzoOBJJQv8votg4gQn/c7LKo0QKDiR3x2NKmGAC6H4Ycbc7iy80x23WQ/5+P DYRMHUs3ZgzhuyvlfXKheC2Dsdsm2XLghsDw8JZIhd9T7lLXx1qnooGpfOCl8JRIQw pBU8fvpvD07ap2aCBOJtTa3MGwlt+CSO+ScCsyLk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] stdio: Fix bugs in commit 3d94e07c49b5 X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/main X-Git-Oldrev: d36b4f3f069881b2613b2754d6492d596c9e6ab9 X-Git-Newrev: bc986b7ff668aa98372fc4e885307339e7ab3f51 Message-Id: <20231120200201.0BA6E3858C5F@sourceware.org> Date: Mon, 20 Nov 2023 20:02:01 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dbc986b7ff66= 8aa98372fc4e885307339e7ab3f51 commit bc986b7ff668aa98372fc4e885307339e7ab3f51 Author: Takashi Yano AuthorDate: Sat Nov 11 01:09:47 2023 +0900 Commit: Corinna Vinschen CommitDate: Mon Nov 20 20:59:12 2023 +0100 stdio: Fix bugs in commit 3d94e07c49b5 =20 The commit 3d94e07c49b5 has a few bugs which cause testsuite failure in libstdc++. This is due to excess orientation check in __srefill_r() and _ungetc_r(). Further, sscanf() family also calls ssvfscanf() family with fp->_file =3D=3D -1. This causes undesired orientation set/check f= or sscanf() family. This patch fixes these problems. =20 Also, as in GLibC, do not set orientation in ungetc, and only set, but do not check orientation in ungetwc. =20 Fixes: 3d94e07c49b5 ("newlib: libc: Fix crash on fprintf to a wide-orie= nted stream.") Reported-by: Christophe Lyon Reported-by: Joel Sherrill Co-developed-by: Corinna Vinschen Signed-off-by: Takashi Yano Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/stdio/asiprintf.c | 2 ++ newlib/libc/stdio/asniprintf.c | 2 ++ newlib/libc/stdio/asnprintf.c | 2 ++ newlib/libc/stdio/asprintf.c | 2 ++ newlib/libc/stdio/getc.c | 6 ++++++ newlib/libc/stdio/refill.c | 3 --- newlib/libc/stdio/siprintf.c | 2 ++ newlib/libc/stdio/siscanf.c | 2 ++ newlib/libc/stdio/sniprintf.c | 2 ++ newlib/libc/stdio/snprintf.c | 2 ++ newlib/libc/stdio/sprintf.c | 2 ++ newlib/libc/stdio/sscanf.c | 2 ++ newlib/libc/stdio/swprintf.c | 2 ++ newlib/libc/stdio/swscanf.c | 2 ++ newlib/libc/stdio/ungetc.c | 6 ------ newlib/libc/stdio/ungetwc.c | 5 ++--- newlib/libc/stdio/vasiprintf.c | 1 + newlib/libc/stdio/vasniprintf.c | 1 + newlib/libc/stdio/vasnprintf.c | 1 + newlib/libc/stdio/vasprintf.c | 1 + newlib/libc/stdio/vsiprintf.c | 1 + newlib/libc/stdio/vsiscanf.c | 1 + newlib/libc/stdio/vsniprintf.c | 1 + newlib/libc/stdio/vsnprintf.c | 1 + newlib/libc/stdio/vsprintf.c | 1 + newlib/libc/stdio/vsscanf.c | 1 + newlib/libc/stdio/vswprintf.c | 1 + 27 files changed, 43 insertions(+), 12 deletions(-) diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c index af25e9a57acd..dedb7fbfabce 100644 --- a/newlib/libc/stdio/asiprintf.c +++ b/newlib/libc/stdio/asiprintf.c @@ -35,6 +35,7 @@ _asiprintf_r (struct _reent *ptr, =20 /* mark a zero-length reallocatable buffer */ f._flags =3D __SWR | __SSTR | __SMBF; + f._flags2 =3D 0; f._bf._base =3D f._p =3D NULL; f._bf._size =3D f._w =3D 0; f._file =3D -1; /* No file. */ @@ -61,6 +62,7 @@ asiprintf (char **strp, =20 /* mark a zero-length reallocatable buffer */ f._flags =3D __SWR | __SSTR | __SMBF; + f._flags2 =3D 0; f._bf._base =3D f._p =3D NULL; f._bf._size =3D f._w =3D 0; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/asniprintf.c b/newlib/libc/stdio/asniprintf.c index 97e77748e75d..e930c8d69f64 100644 --- a/newlib/libc/stdio/asniprintf.c +++ b/newlib/libc/stdio/asniprintf.c @@ -36,6 +36,7 @@ _asniprintf_r (struct _reent *ptr, len =3D 0; buf =3D NULL; } + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t @@ -82,6 +83,7 @@ asniprintf (char *buf, len =3D 0; buf =3D NULL; } + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/asnprintf.c b/newlib/libc/stdio/asnprintf.c index f82556143e74..4c9ad586020a 100644 --- a/newlib/libc/stdio/asnprintf.c +++ b/newlib/libc/stdio/asnprintf.c @@ -36,6 +36,7 @@ _asnprintf_r (struct _reent *__restrict ptr, len =3D 0; buf =3D NULL; } + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t @@ -88,6 +89,7 @@ asnprintf (char *__restrict buf, len =3D 0; buf =3D NULL; } + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index 542e70e4c308..511d0e0f3f4a 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -35,6 +35,7 @@ _asprintf_r (struct _reent *ptr, =20 /* mark a zero-length reallocatable buffer */ f._flags =3D __SWR | __SSTR | __SMBF; + f._flags2 =3D 0; f._bf._base =3D f._p =3D NULL; f._bf._size =3D f._w =3D 0; f._file =3D -1; /* No file. */ @@ -67,6 +68,7 @@ asprintf (char **__restrict strp, =20 /* mark a zero-length reallocatable buffer */ f._flags =3D __SWR | __SSTR | __SMBF; + f._flags2 =3D 0; f._bf._base =3D f._p =3D NULL; f._bf._size =3D f._w =3D 0; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c index c8781320e603..12bffaf8f79a 100644 --- a/newlib/libc/stdio/getc.c +++ b/newlib/libc/stdio/getc.c @@ -81,6 +81,9 @@ _getc_r (struct _reent *ptr, { int result; CHECK_INIT (ptr, fp); + if (ORIENT (fp, -1) !=3D -1) + return EOF; + _newlib_flockfile_start (fp); result =3D __sgetc_r (ptr, fp); _newlib_flockfile_end (fp); @@ -96,6 +99,9 @@ getc (register FILE *fp) struct _reent *reent =3D _REENT; =20 CHECK_INIT (reent, fp); + if (ORIENT (fp, -1) !=3D -1) + return EOF; + _newlib_flockfile_start (fp); result =3D __sgetc_r (reent, fp); _newlib_flockfile_end (fp); diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index c1ef7e120b71..cd71ed1529ba 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -43,9 +43,6 @@ __srefill_r (struct _reent * ptr, =20 CHECK_INIT (ptr, fp); =20 - if (ORIENT (fp, -1) !=3D -1) - return EOF; - fp->_r =3D 0; /* largely a convenience for callers */ =20 /* SysV does not make this test; take it out for compatibility */ diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index bd29edd88110..b337925979bb 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -108,6 +108,7 @@ _siprintf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D INT_MAX; f._file =3D -1; /* No file. */ @@ -129,6 +130,7 @@ siprintf (char *str, FILE f; =20 f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D INT_MAX; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/siscanf.c b/newlib/libc/stdio/siscanf.c index b88b81088818..4c1363d0a766 100644 --- a/newlib/libc/stdio/siscanf.c +++ b/newlib/libc/stdio/siscanf.c @@ -90,6 +90,7 @@ siscanf (const char *str, FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D strlen (str); f._read =3D __seofread; @@ -114,6 +115,7 @@ _siscanf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D strlen (str); f._read =3D __seofread; diff --git a/newlib/libc/stdio/sniprintf.c b/newlib/libc/stdio/sniprintf.c index b05ffcb12da9..852713f1ffb8 100644 --- a/newlib/libc/stdio/sniprintf.c +++ b/newlib/libc/stdio/sniprintf.c @@ -42,6 +42,7 @@ _sniprintf_r (struct _reent *ptr, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? size - 1 : 0); f._file =3D -1; /* No file. */ @@ -73,6 +74,7 @@ sniprintf (char *str, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? size - 1 : 0); f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index 4a3084beacb3..b6130b998393 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -41,6 +41,7 @@ _snprintf_r (struct _reent *ptr, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? size - 1 : 0); f._file =3D -1; /* No file. */ @@ -78,6 +79,7 @@ snprintf (char *__restrict str, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? size - 1 : 0); f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index be66ec6f5d73..92cae46189df 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -584,6 +584,7 @@ _sprintf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D INT_MAX; f._file =3D -1; /* No file. */ @@ -611,6 +612,7 @@ sprintf (char *__restrict str, FILE f; =20 f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D INT_MAX; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index 9c50361bc026..52145fc46c20 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -429,6 +429,7 @@ sscanf (const char *__restrict str, FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D strlen (str); f._read =3D __seofread; @@ -459,6 +460,7 @@ _sscanf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D strlen (str); f._read =3D __seofread; diff --git a/newlib/libc/stdio/swprintf.c b/newlib/libc/stdio/swprintf.c index 634b22beb909..e590b522ced8 100644 --- a/newlib/libc/stdio/swprintf.c +++ b/newlib/libc/stdio/swprintf.c @@ -568,6 +568,7 @@ _swprintf_r (struct _reent *ptr, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? (size - 1) * sizeof (wchar_t) : 0); f._file =3D -1; /* No file. */ @@ -608,6 +609,7 @@ swprintf (wchar_t *__restrict str, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? (size - 1) * sizeof (wchar_t) : 0); f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/swscanf.c b/newlib/libc/stdio/swscanf.c index 578ac3c93f76..0ef4d0ebde18 100644 --- a/newlib/libc/stdio/swscanf.c +++ b/newlib/libc/stdio/swscanf.c @@ -422,6 +422,7 @@ swscanf (const wchar_t *__restrict str, const wchar_t *= __restrict fmt, ...) FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D wcslen (str) * sizeof (wchar_t); f._read =3D __seofread; @@ -446,6 +447,7 @@ _swscanf_r (struct _reent *ptr, const wchar_t *str, con= st wchar_t *fmt, ...) FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D wcslen (str) * sizeof (wchar_t); f._read =3D __seofread; diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c index 79914af0806e..8b10c8218616 100644 --- a/newlib/libc/stdio/ungetc.c +++ b/newlib/libc/stdio/ungetc.c @@ -125,12 +125,6 @@ _ungetc_r (struct _reent *rptr, =20 _newlib_flockfile_start (fp); =20 - if (ORIENT (fp, -1) !=3D -1) - { - _newlib_flockfile_exit (fp); - return EOF; - } - /* After ungetc, we won't be at eof anymore */ fp->_flags &=3D ~__SEOF; =20 diff --git a/newlib/libc/stdio/ungetwc.c b/newlib/libc/stdio/ungetwc.c index 18636d773edd..16d37f2d176c 100644 --- a/newlib/libc/stdio/ungetwc.c +++ b/newlib/libc/stdio/ungetwc.c @@ -82,9 +82,8 @@ _ungetwc_r (struct _reent *ptr, size_t len; =20 _newlib_flockfile_start (fp); - if (ORIENT (fp, 1) !=3D 1) - wc =3D WEOF; - else if (wc =3D=3D WEOF) + ORIENT (fp, 1); + if (wc =3D=3D WEOF) wc =3D WEOF; else if ((len =3D _wcrtomb_r(ptr, buf, wc, &fp->_mbstate)) =3D=3D (size_= t)-1) { diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c index 1deb2dbcf3d8..d9c11eaf503f 100644 --- a/newlib/libc/stdio/vasiprintf.c +++ b/newlib/libc/stdio/vasiprintf.c @@ -50,6 +50,7 @@ _vasiprintf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SWR | __SSTR | __SMBF ; + f._flags2 =3D 0; f._bf._base =3D f._p =3D NULL; f._bf._size =3D f._w =3D 0; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/vasniprintf.c b/newlib/libc/stdio/vasniprint= f.c index b24cd96fb625..c85ca06e8c1a 100644 --- a/newlib/libc/stdio/vasniprintf.c +++ b/newlib/libc/stdio/vasniprintf.c @@ -36,6 +36,7 @@ _vasniprintf_r (struct _reent *ptr, len =3D 0; buf =3D NULL; } + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/vasnprintf.c b/newlib/libc/stdio/vasnprintf.c index b3787ec7a1fa..02f55caa9a95 100644 --- a/newlib/libc/stdio/vasnprintf.c +++ b/newlib/libc/stdio/vasnprintf.c @@ -36,6 +36,7 @@ _vasnprintf_r (struct _reent *ptr, len =3D 0; buf =3D NULL; } + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index d7ec9c8400ef..b466936bd94b 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -56,6 +56,7 @@ _vasprintf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SWR | __SSTR | __SMBF ; + f._flags2 =3D 0; f._bf._base =3D f._p =3D NULL; f._bf._size =3D f._w =3D 0; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/vsiprintf.c b/newlib/libc/stdio/vsiprintf.c index 8128cb772684..af07ad85e8cd 100644 --- a/newlib/libc/stdio/vsiprintf.c +++ b/newlib/libc/stdio/vsiprintf.c @@ -50,6 +50,7 @@ _vsiprintf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D INT_MAX; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/vsiscanf.c b/newlib/libc/stdio/vsiscanf.c index d7135ef71278..4e28d1079390 100644 --- a/newlib/libc/stdio/vsiscanf.c +++ b/newlib/libc/stdio/vsiscanf.c @@ -49,6 +49,7 @@ _vsiscanf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D strlen (str); f._read =3D __seofread; diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprintf.c index e7625ffd5345..a50a0a993115 100644 --- a/newlib/libc/stdio/vsniprintf.c +++ b/newlib/libc/stdio/vsniprintf.c @@ -58,6 +58,7 @@ _vsniprintf_r (struct _reent *ptr, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? size - 1 : 0); f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index ecf82eaefff7..d9c72b526ba5 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -64,6 +64,7 @@ _vsnprintf_r (struct _reent *ptr, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? size - 1 : 0); f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/vsprintf.c b/newlib/libc/stdio/vsprintf.c index 4d51fd0dc03f..4d4619fd0324 100644 --- a/newlib/libc/stdio/vsprintf.c +++ b/newlib/libc/stdio/vsprintf.c @@ -56,6 +56,7 @@ _vsprintf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D INT_MAX; f._file =3D -1; /* No file. */ diff --git a/newlib/libc/stdio/vsscanf.c b/newlib/libc/stdio/vsscanf.c index e9e84088f7cf..6150f541bb24 100644 --- a/newlib/libc/stdio/vsscanf.c +++ b/newlib/libc/stdio/vsscanf.c @@ -55,6 +55,7 @@ _vsscanf_r (struct _reent *ptr, FILE f; =20 f._flags =3D __SRD | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._r =3D strlen (str); f._read =3D __seofread; diff --git a/newlib/libc/stdio/vswprintf.c b/newlib/libc/stdio/vswprintf.c index 08a8545baef8..ab2e52ff4921 100644 --- a/newlib/libc/stdio/vswprintf.c +++ b/newlib/libc/stdio/vswprintf.c @@ -46,6 +46,7 @@ _vswprintf_r (struct _reent *ptr, return EOF; } f._flags =3D __SWR | __SSTR; + f._flags2 =3D 0; f._bf._base =3D f._p =3D (unsigned char *) str; f._bf._size =3D f._w =3D (size > 0 ? (size - 1) * sizeof (wchar_t) : 0); f._file =3D -1; /* No file. */