about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBirunthan Mohanathas <birunthan@mohanathas.com>2013-09-01 14:57:29 +0300
committerBirunthan Mohanathas <birunthan@mohanathas.com>2013-09-01 14:57:29 +0300
commit30fc2c8df2fc565b20d8df3a202cb0c7d089afd0 (patch)
tree42c9b28af8ee457d0ce351ede49b1bfa0feef19e /src
parent617850131b795312c4dd404ae7d853b54d883105 (diff)
downloadrust-30fc2c8df2fc565b20d8df3a202cb0c7d089afd0.tar.gz
rust-30fc2c8df2fc565b20d8df3a202cb0c7d089afd0.zip
Fix incorrect strftime error handling in rust_localtime
Closes #8702.
Diffstat (limited to 'src')
-rw-r--r--src/rt/rust_builtin.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 27cc486c39e..03a17d2c2ef 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -321,13 +321,16 @@ rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
     time_t s = sec;
     LOCALTIME(&s, &tm);
 
+    const char* zone = NULL;
 #if defined(__WIN32__)
     int32_t gmtoff = -timezone;
-    char zone[64];
-    strftime(zone, sizeof(zone), "%Z", &tm);
+    char buffer[64];
+    if (strftime(buffer, sizeof(buffer), "%Z", &tm) > 0) {
+        zone = buffer;
+    }
 #else
     int32_t gmtoff = tm.tm_gmtoff;
-    const char *zone = tm.tm_zone;
+    zone = tm.tm_zone;
 #endif
 
     tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);