From: John Darrington Date: Sat, 21 Mar 2009 06:12:47 +0000 (+0900) Subject: Fix crash when running under windows with non-english locale X-Git-Tag: v0.7.3~211 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=275fecdac3c7104f1095ec940cb1e2a6113872cd;p=pspp-builds.git Fix crash when running under windows with non-english locale Fixed a bug which manifested itself when running a Mingw compiled binary with a non-english locale. setlocale returns a statically allocated string, so it's valid only until the next call to setlocale. Thanks to Michel Boaventura for reporting and helping to diagnose this problem. --- diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index db851217..1028d0be 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -227,7 +227,7 @@ get_system_decimal (void) { char radix_char; - char *ol = setlocale (LC_NUMERIC, NULL); + char *ol = strdup (setlocale (LC_NUMERIC, NULL)); setlocale (LC_NUMERIC, ""); #if HAVE_NL_LANGINFO @@ -243,6 +243,7 @@ get_system_decimal (void) /* We MUST leave LC_NUMERIC untouched, since it would otherwise interfere with data_{in,out} */ setlocale (LC_NUMERIC, ol); + free (ol); return radix_char; }