summaryrefslogtreecommitdiff
path: root/ext/POSIX/POSIX.xs
diff options
context:
space:
mode:
authorSteve Hay <SteveHay@planit.com>2007-06-27 17:08:01 +0000
committerSteve Hay <SteveHay@planit.com>2007-06-27 17:08:01 +0000
commit1ba01ae30179f2a8998a11d70df713a205922f5f (patch)
tree6f739eb9e499e06698ffde4cbd813b8cb81f1aa0 /ext/POSIX/POSIX.xs
parent13201e38d406ff98a98fa209237f36b0a2beb8e5 (diff)
downloadperl-1ba01ae30179f2a8998a11d70df713a205922f5f.tar.gz
Fix POSIX::setlocale(): the CRT function returns a pointer to a
buffer that may be overwritten by subsequent calls to the CRT function, so we must make a safe copy of that buffer for our own use. This fixes lib/locale.t on Win32 with the Borland compiler, but presumably could affect other compilers too. p4raw-id: //depot/perl@31482
Diffstat (limited to 'ext/POSIX/POSIX.xs')
-rw-r--r--ext/POSIX/POSIX.xs15
1 files changed, 12 insertions, 3 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 388a260244..9ddfd3ae48 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -1108,9 +1108,14 @@ char *
setlocale(category, locale = 0)
int category
char * locale
+ PREINIT:
+ char * retval;
CODE:
- RETVAL = setlocale(category, locale);
- if (RETVAL) {
+ retval = setlocale(category, locale);
+ if (retval) {
+ /* Save retval since subsequent setlocale() calls
+ * may overwrite it. */
+ RETVAL = savepv(retval);
#ifdef USE_LOCALE_CTYPE
if (category == LC_CTYPE
#ifdef LC_ALL
@@ -1163,9 +1168,13 @@ setlocale(category, locale = 0)
}
#endif /* USE_LOCALE_NUMERIC */
}
+ else
+ RETVAL = NULL;
OUTPUT:
RETVAL
-
+ CLEANUP:
+ if (RETVAL)
+ Safefree(RETVAL);
NV
acos(x)