summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/config/locale/generic/time_members.cc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libstdc++/config/locale/generic/time_members.cc')
-rw-r--r--contrib/libstdc++/config/locale/generic/time_members.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/libstdc++/config/locale/generic/time_members.cc b/contrib/libstdc++/config/locale/generic/time_members.cc
index 6e2f755..f27b2a0 100644
--- a/contrib/libstdc++/config/locale/generic/time_members.cc
+++ b/contrib/libstdc++/config/locale/generic/time_members.cc
@@ -46,9 +46,12 @@ namespace std
{
char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_timepunct);
- strftime(__s, __maxlen, __format, __tm);
+ const size_t __len = strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
free(__old);
+ // Make sure __s is null terminated.
+ if (__len == 0)
+ __s[0] = '\0';
}
template<>
@@ -125,9 +128,12 @@ namespace std
{
char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_timepunct);
- wcsftime(__s, __maxlen, __format, __tm);
+ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
free(__old);
+ // Make sure __s is null terminated.
+ if (__len == 0)
+ __s[0] = L'\0';
}
template<>
OpenPOWER on IntegriCloud