about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2003-03-10 15:23:44 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2003-03-10 15:23:44 +0000
commit1d80cc9acf21080119a9c2704ca2a15aa09d1659 (patch)
tree86cbc9628a81f8f9df6a004c7686e066081e5f1a
parenta8a7df84edbd9b5fb2b8076dabd3bea59ea30b61 (diff)
downloadzsh-1d80cc9acf21080119a9c2704ca2a15aa09d1659.tar.gz
zsh-1d80cc9acf21080119a9c2704ca2a15aa09d1659.tar.xz
zsh-1d80cc9acf21080119a9c2704ca2a15aa09d1659.zip
18330: save output of setlocale as the pointer it returns gets clobbered
-rw-r--r--ChangeLog3
-rw-r--r--Src/math.c4
2 files changed, 5 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index bf11b56dc..698492e1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-03-10  Oliver Kiddle  <opk@zsh.org>
 
+	* 18330: Src/math.c: save output of setlocale as the pointer it
+	returns gets clobbered
+
 	* 18331: Completion/Unix/Command/_mh: use _call_program to avoid
 	command not found errors, handle prefix-hidden style, make use of
 	_email_addresses and complete for more mh commands
diff --git a/Src/math.c b/Src/math.c
index bc0669b7e..dc75a8143 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -399,12 +399,12 @@ zzlex(void)
 		    /* it's a float */
 		    yyval.type = MN_FLOAT;
 #ifdef USE_LOCALE
-		    prev_locale = setlocale(LC_NUMERIC, NULL);
+		    prev_locale = dupstring(setlocale(LC_NUMERIC, NULL));
 		    setlocale(LC_NUMERIC, "POSIX");
 #endif
 		    yyval.u.d = strtod(ptr, &nptr);
 #ifdef USE_LOCALE
-		    setlocale(LC_NUMERIC, prev_locale);
+		    if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
 #endif
 		    if (ptr == nptr || *nptr == '.') {
 			zerr("bad floating point constant", NULL, 0);