From 36bc7e4c3f91c560df8051afedddea3f49474264 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Sun, 25 Dec 2016 10:51:34 +0100 Subject: [PATCH] store old locale to a temporary variable On Windows XP 32 bit setLocale seems to cause old pointer invalidation and causes program crash in destructor. This was causing CPackZIP to crash so to fix it we copy the value into a temporary variable. --- Source/cmLocale.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmLocale.h b/Source/cmLocale.h index e8e751d1d9..cca7cf5491 100644 --- a/Source/cmLocale.h +++ b/Source/cmLocale.h @@ -6,10 +6,11 @@ #include #include +#include class cmLocaleRAII { - const char* OldLocale; + std::string OldLocale; public: cmLocaleRAII() @@ -17,7 +18,7 @@ public: { setlocale(LC_CTYPE, ""); } - ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale); } + ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale.c_str()); } }; #endif