aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/siprintf.c
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2023-11-11 01:09:47 +0900
committerCorinna Vinschen <corinna@vinschen.de>2023-11-20 20:59:12 +0100
commitbc986b7ff668aa98372fc4e885307339e7ab3f51 (patch)
tree4a8b16525b74690bafcebe896c427c3ae94a025f /newlib/libc/stdio/siprintf.c
parentd36b4f3f069881b2613b2754d6492d596c9e6ab9 (diff)
downloadnewlib-bc986b7ff668aa98372fc4e885307339e7ab3f51.zip
newlib-bc986b7ff668aa98372fc4e885307339e7ab3f51.tar.gz
newlib-bc986b7ff668aa98372fc4e885307339e7ab3f51.tar.bz2
stdio: Fix bugs in commit 3d94e07c49b5
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 == -1. This causes undesired orientation set/check for sscanf() family. This patch fixes these problems. Also, as in GLibC, do not set orientation in ungetc, and only set, but do not check orientation in ungetwc. Fixes: 3d94e07c49b5 ("newlib: libc: Fix crash on fprintf to a wide-oriented stream.") Reported-by: Christophe Lyon <christophe.lyon@linaro.org> Reported-by: Joel Sherrill <joel@rtems.org> Co-developed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'newlib/libc/stdio/siprintf.c')
-rw-r--r--newlib/libc/stdio/siprintf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c
index bd29edd..b337925 100644
--- a/newlib/libc/stdio/siprintf.c
+++ b/newlib/libc/stdio/siprintf.c
@@ -108,6 +108,7 @@ _siprintf_r (struct _reent *ptr,
FILE f;
f._flags = __SWR | __SSTR;
+ f._flags2 = 0;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = INT_MAX;
f._file = -1; /* No file. */
@@ -129,6 +130,7 @@ siprintf (char *str,
FILE f;
f._flags = __SWR | __SSTR;
+ f._flags2 = 0;
f._bf._base = f._p = (unsigned char *) str;
f._bf._size = f._w = INT_MAX;
f._file = -1; /* No file. */