Change 31482 by [EMAIL PROTECTED] on 2007/06/27 17:08:01

        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.

Affected files ...

... //depot/perl/ext/POSIX/POSIX.xs#148 edit

Differences ...

==== //depot/perl/ext/POSIX/POSIX.xs#148 (text) ====
Index: perl/ext/POSIX/POSIX.xs
--- perl/ext/POSIX/POSIX.xs#147~30898~  2007-04-10 11:56:17.000000000 -0700
+++ perl/ext/POSIX/POSIX.xs     2007-06-27 10:08:01.000000000 -0700
@@ -1108,9 +1108,14 @@
 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 @@
            }
 #endif /* USE_LOCALE_NUMERIC */
        }
+       else
+           RETVAL = NULL;
     OUTPUT:
        RETVAL
-
+    CLEANUP:
+        if (RETVAL)
+           Safefree(RETVAL);
 
 NV
 acos(x)
End of Patch.

Reply via email to