From 275fecdac3c7104f1095ec940cb1e2a6113872cd Mon Sep 17 00:00:00 2001
From: John Darrington <john@darrington.wattle.id.au>
Date: Sat, 21 Mar 2009 15:12:47 +0900
Subject: [PATCH] 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.
---
 src/libpspp/i18n.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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;
 }
 
-- 
2.30.2