diff mbox series

[v2] libio: do not cleanup wide buffers of legacy standard files [BZ #24228]

Message ID 20190218213809.GA27785@altlinux.org
State New
Headers show
Series [v2] libio: do not cleanup wide buffers of legacy standard files [BZ #24228] | expand

Commit Message

Dmitry V. Levin Feb. 18, 2019, 9:38 p.m. UTC
Commit glibc-2.23~693 (a601b74d31ca086de38441d316a3dee24c866305)
introduced a regression: _IO_unbuffer_all() now invokes _IO_wsetb() to
free wide buffers of all files, including legacy standard files that
are small statically allocated objects that do not have wide buffers
and the _mode member.

Fix this by skipping _IO_wsetb() invocation for legacy standard files.

[BZ #24228]
* libio/genops.c (_IO_unbuffer_all)
[SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)]: Skip _IO_wsetb() invocation
for legacy standard files in compatibility mode.
---
 ChangeLog      | 7 +++++++
 libio/genops.c | 7 +++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libio/genops.c b/libio/genops.c
index 2a0d9b81df..95d53595a2 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -816,8 +816,11 @@  _IO_unbuffer_all (void)
 
 	  _IO_SETBUF (fp, NULL, 0);
 
-	  if (fp->_mode > 0)
-	    _IO_wsetb (fp, NULL, NULL, 0);
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+	  if (__glibc_likely (&_IO_stdin_used != NULL) || !_IO_legacy_file (fp))
+#endif
+	    if (fp->_mode > 0)
+	      _IO_wsetb (fp, NULL, NULL, 0);
 
 #ifdef _IO_MTSAFE_IO
 	  if (cnt < MAXTRIES && fp->_lock != NULL)