From 03715a64e0fc5c7c6f9ebfb8a25b2454ddd28011 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:09:26 +0100 Subject: [PATCH] Changed: Check if LC_NUMERIC is correct before loading or saving config files --- code/nel/src/misc/config_file/config_file.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index 093992487..bab1c123b 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -316,6 +316,13 @@ CConfigFile::~CConfigFile () void CConfigFile::load (const string &fileName, bool lookupPaths ) { + char *locale = setlocale(LC_NUMERIC, NULL); + + if (!locale || strcmp(locale, "C")) + { + nlerror("Numeric locale not defined to C, an external library possibly redefined it!"); + } + if(fileName.empty()) { nlwarning ("CF: Can't load a empty file name configfile"); @@ -597,8 +604,12 @@ bool CConfigFile::exists (const std::string &varName) void CConfigFile::save () const { - // Avoid any problem, Force Locale to default - setlocale(LC_ALL, "C"); + char *locale = setlocale(LC_NUMERIC, NULL); + + if (!locale || strcmp(locale, "C")) + { + nlerror("Numeric locale not defined to C, an external library possibly redefined it!"); + } FILE *fp = nlfopen (getFilename(), "w"); if (fp == NULL)