aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/pj_init.c10
2 files changed, 10 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c743cb3e..9a9f337c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-02-21 Frank Warmerdam <warmerdam@pobox.com>
+ * src/pj_init.c: fix serious bug in locale handling, wasn't copying
+ the old locale so it would sometimes get corrupted.
+
* src/proj_etmerc.c: added extended transverse mercator impl. (#97)
* Rerun autogen.sh with the latest versions of automake, autoconf and
diff --git a/src/pj_init.c b/src/pj_init.c
index bffbf786..26f32d1a 100644
--- a/src/pj_init.c
+++ b/src/pj_init.c
@@ -241,8 +241,9 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
ctx->last_errno = 0;
start = NULL;
- old_locale = setlocale(LC_NUMERIC, NULL);
- setlocale(LC_NUMERIC,"C");
+ old_locale = strdup(setlocale(LC_NUMERIC, NULL));
+ if( strcmp(old_locale,"C") != 0 )
+ setlocale(LC_NUMERIC,"C");
/* put arguments into internal linked list */
if (argc <= 0) { pj_ctx_set_errno( ctx, -1 ); goto bum_call; }
@@ -433,7 +434,10 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
}
PIN = 0;
}
- setlocale(LC_NUMERIC,old_locale);
+
+ if( strcmp(old_locale,"C") != 0 )
+ setlocale(LC_NUMERIC,old_locale);
+ free( old_locale );
return PIN;
}