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.
This commit is contained in:
Domen Vrankar 2016-12-25 10:51:34 +01:00
parent 05c14ea0a9
commit 36bc7e4c3f

View File

@ -6,10 +6,11 @@
#include <cmConfigure.h>
#include <locale.h>
#include <string>
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