From 0d0a41d54924e641a7a6e79303abcad20e293034 Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Thu, 11 May 2023 14:00:45 -0700 Subject: [PATCH] Fix locale management on Windows. We are currently passing a value previously returned by setlocale to a later call to setlocale, but the spec says that we should be making a copy of it. PiperOrigin-RevId: 531300386 Change-Id: I9531cfe738fc71fb26b4140a4129dfe67f5f6112 --- src/xml/xml.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xml/xml.cc b/src/xml/xml.cc index b15a3a8a..7dbc7022 100644 --- a/src/xml/xml.cc +++ b/src/xml/xml.cc @@ -62,13 +62,13 @@ class LocaleOverride { } ~LocaleOverride() { - setlocale(LC_ALL, old_locale_); + setlocale(LC_ALL, old_locale_.c_str()); _configthreadlocale(old_per_thread_locale_type_); } private: int old_per_thread_locale_type_; - char* old_locale_; + std::string old_locale_; }; #else class LocaleOverride {