]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
locale_facets.tcc (__convert_from_v): Replace strdup with ISO malloc and strcpy.
authorDanny Smith <dannysmith@users.sourceforge.net>
Tue, 10 Sep 2002 02:51:49 +0000 (02:51 +0000)
committerDanny Smith <dannysmith@gcc.gnu.org>
Tue, 10 Sep 2002 02:51:49 +0000 (02:51 +0000)
* include/bits/locale_facets.tcc (__convert_from_v):
Replace strdup with ISO malloc and strcpy.

From-SVN: r56992

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc

index 7768faeadffac70c91f82a9cc0b9e459e644f7af..1d749ac8409a93f0133e4624399cac8d1b3d50a3 100644 (file)
@@ -1,3 +1,8 @@
+2002-09-10  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       * include/bits/locale_facets.tcc (__convert_from_v):
+       Replace strdup with ISO malloc and strcpy.
+
 2002-09-09  Benjamin Kosnik  <bkoz@redhat.com>
 
        * src/misc-inst.cc: Remove some instantiations.
index 63e52c0058511997f885920db598dd8f35e057e2..ad7ba3f5320362a28f317a9209943e9a34f9f8c4 100644 (file)
@@ -1976,14 +1976,17 @@ namespace std
                     _Tv __v, const __c_locale&, int __prec = -1)
     {
       int __ret;
-      char* __old = strdup(setlocale(LC_ALL, NULL));
+      char* __old = setlocale(LC_ALL, NULL);
+      char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
+      if (__sav)
+        strcpy(__sav, __old);
       setlocale(LC_ALL, "C");
       if (__prec >= 0)
         __ret = snprintf(__out, __size, __fmt, __prec, __v);
       else
         __ret = snprintf(__out, __size, __fmt, __v);
-      setlocale(LC_ALL, __old);
-      free(__old);
+      setlocale(LC_ALL, __sav);
+      free(__sav);
       return __ret;
     }
 #else
@@ -1993,14 +1996,17 @@ namespace std
                     const __c_locale&, int __prec = -1)
     {
       int __ret;
-      char* __old = strdup(setlocale(LC_ALL, NULL));
+      char* __old = setlocale(LC_ALL, NULL);
+      char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
+      if (__sav)
+        strcpy(__sav, __old);
       setlocale(LC_ALL, "C");
       if (__prec >= 0)
         __ret = sprintf(__out, __fmt, __prec, __v);
       else
         __ret = sprintf(__out, __fmt, __v);
-      setlocale(LC_ALL, __old);
-      free(__old);
+      setlocale(LC_ALL, __sav);
+      free(__sav);
       return __ret;
     }
 #endif