locale_facets.tcc (__convert_from_v): Replace strdup with ISO malloc and strcpy.
authorDanny Smith <dannysmith@users.sourceforge.net>
Tue, 10 Sep 2002 02:41:55 +0000 (02:41 +0000)
committerDanny Smith <dannysmith@gcc.gnu.org>
Tue, 10 Sep 2002 02:41:55 +0000 (02:41 +0000)
* include/bits/locale_facets.tcc (__convert_from_v):
Replace strdup with ISO malloc and strcpy.

From-SVN: r56991

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

index 787792ad612c6f35784f67e7fc6437962f066630..e89c6187ae736f7b9dfc0259f4d57ccd6f3a1e2d 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>
 
        * docs/html/configopts.html: Change grouping. Note ABI impacts.
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