瀏覽代碼

LibC: Ensure tzname and related fields are intialized

If a program never invokes tzset, the tzname variable should have system
dependent default values.
Timothy Flynn 3 年之前
父節點
當前提交
024f869f09
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      Userland/Libraries/LibC/time.cpp

+ 5 - 5
Userland/Libraries/LibC/time.cpp

@@ -354,15 +354,15 @@ size_t strftime(char* destination, size_t max_size, const char* format, const st
     return fits ? str.length() : 0;
 }
 
-long timezone;
-long altzone;
-char* tzname[2];
-int daylight;
-
 static char __tzname_standard[TZNAME_MAX];
 static char __tzname_daylight[TZNAME_MAX];
 constexpr const char* __utc = "UTC";
 
+long timezone = 0;
+long altzone = 0;
+char* tzname[2] = { const_cast<char*>(__utc), const_cast<char*>(__utc) };
+int daylight = 0;
+
 void tzset()
 {
     // FIXME: Actually parse the TZ environment variable, described here: