locale_facets.tcc (__convert_from_v): Replace strdup with ISO malloc and strcpy.

* include/bits/locale_facets.tcc (__convert_from_v):
	Replace strdup with ISO malloc and strcpy.

From-SVN: r56991
This commit is contained in:
Danny Smith 2002-09-10 02:41:55 +00:00 committed by Danny Smith
parent 686f3bf031
commit 57c4e0cd35
2 changed files with 17 additions and 6 deletions

View 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.

View 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