[cfe-commits] [libcxx] r150929 - /libcxx/trunk/src/locale.cpp

Howard Hinnant hhinnant at apple.com
Sun Feb 19 06:55:32 PST 2012


Author: hhinnant
Date: Sun Feb 19 08:55:32 2012
New Revision: 150929

URL: http://llvm.org/viewvc/llvm-project?rev=150929&view=rev
Log:
Initialize all the fields of struct tm before passing it to strftime. One of the uninitialized fields, probably the pointer field tm_zone, was causing a segfault on linux.  Patch contributed by Jeffrey Yasskin.

Modified:
    libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=150929&r1=150928&r2=150929&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Sun Feb 19 08:55:32 2012
@@ -4551,7 +4551,7 @@
 string
 __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
 {
-    tm t;
+    tm t = {0};
     t.tm_sec = 59;
     t.tm_min = 55;
     t.tm_hour = 23;
@@ -4698,7 +4698,7 @@
 wstring
 __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
 {
-    tm t;
+    tm t = {0};
     t.tm_sec = 59;
     t.tm_min = 55;
     t.tm_hour = 23;





More information about the cfe-commits mailing list