From patchwork Mon Feb 18 12:44:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dmitry V. Levin" X-Patchwork-Id: 31496 Received: (qmail 114974 invoked by alias); 18 Feb 2019 12:44:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 114960 invoked by uid 89); 18 Feb 2019 12:44:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1141 X-HELO: vmicros1.altlinux.org Date: Mon, 18 Feb 2019 15:44:39 +0300 From: "Dmitry V. Levin" To: libc-alpha@sourceware.org Subject: [PATCH] libio: do not cleanup wide buffers of legacy standard files [BZ #24228] Message-ID: <20190218124438.GB20127@altlinux.org> MIME-Version: 1.0 Content-Disposition: inline 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. 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. --- ChangeLog | 7 +++++++ libio/genops.c | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libio/genops.c b/libio/genops.c index 2a0d9b81df..c53696f2e0 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 (!_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)