aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.7
diff options
context:
space:
mode:
authorAndrew Hsieh <andrewhsieh@google.com>2013-03-09 01:27:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-03-09 01:27:34 +0000
commite88c4f52a771a323dfad124e5f4836c2504a0905 (patch)
treede6d5048d13e2b59636273cc2f56ae33fd44403b /gcc-4.7
parent0b98b2a6adcc38619dd07fcd1b6638b7795c24c3 (diff)
parentd3029b5a1a770d75806370618f7311a991107119 (diff)
downloadtoolchain_gcc-e88c4f52a771a323dfad124e5f4836c2504a0905.zip
toolchain_gcc-e88c4f52a771a323dfad124e5f4836c2504a0905.tar.gz
toolchain_gcc-e88c4f52a771a323dfad124e5f4836c2504a0905.tar.bz2
Merge "More fix to handle NULL return value of setlocale() in libstdc++/GCC4.7"
Diffstat (limited to 'gcc-4.7')
-rw-r--r--gcc-4.7/libstdc++-v3/config/locale/generic/c_locale.cc24
-rw-r--r--gcc-4.7/libstdc++-v3/config/locale/generic/time_members.cc12
2 files changed, 24 insertions, 12 deletions
diff --git a/gcc-4.7/libstdc++-v3/config/locale/generic/c_locale.cc b/gcc-4.7/libstdc++-v3/config/locale/generic/c_locale.cc
index a89c16f..783bf30 100644
--- a/gcc-4.7/libstdc++-v3/config/locale/generic/c_locale.cc
+++ b/gcc-4.7/libstdc++-v3/config/locale/generic/c_locale.cc
@@ -121,10 +121,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// Assumes __s formatted for "C" locale.
char* __old = setlocale(LC_ALL, 0);
- const size_t __len = strlen(__old) + 1;
- char* __sav = new char[__len];
- memcpy(__sav, __old, __len);
- setlocale(LC_ALL, "C");
+ char* __sav = 0;
+ if (__old)
+ {
+ const size_t __len = strlen(__old) + 1;
+ __sav = new char[__len];
+ memcpy(__sav, __old, __len);
+ setlocale(LC_ALL, "C");
+ }
char* __sanity;
#if !__DBL_HAS_INFINITY__
@@ -166,10 +170,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// Assumes __s formatted for "C" locale.
char* __old = setlocale(LC_ALL, 0);
- const size_t __len = strlen(__old) + 1;
- char* __sav = new char[__len];
- memcpy(__sav, __old, __len);
- setlocale(LC_ALL, "C");
+ char* __sav = 0;
+ if (__old)
+ {
+ const size_t __len = strlen(__old) + 1;
+ __sav = new char[__len];
+ memcpy(__sav, __old, __len);
+ setlocale(LC_ALL, "C");
+ }
#if !__LDBL_HAS_INFINITY__
errno = 0;
diff --git a/gcc-4.7/libstdc++-v3/config/locale/generic/time_members.cc b/gcc-4.7/libstdc++-v3/config/locale/generic/time_members.cc
index a260904..724dd26 100644
--- a/gcc-4.7/libstdc++-v3/config/locale/generic/time_members.cc
+++ b/gcc-4.7/libstdc++-v3/config/locale/generic/time_members.cc
@@ -134,10 +134,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const tm* __tm) const throw()
{
char* __old = setlocale(LC_ALL, 0);
- const size_t __llen = strlen(__old) + 1;
- char* __sav = new char[__llen];
- memcpy(__sav, __old, __llen);
- setlocale(LC_ALL, _M_name_timepunct);
+ char* __sav = 0;
+ if (__old)
+ {
+ const size_t __llen = strlen(__old) + 1;
+ __sav = new char[__llen];
+ memcpy(__sav, __old, __llen);
+ setlocale(LC_ALL, _M_name_timepunct);
+ }
const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __sav);
delete [] __sav;