diff options
| author | Birunthan Mohanathas <birunthan@mohanathas.com> | 2013-09-01 14:57:29 +0300 |
|---|---|---|
| committer | Birunthan Mohanathas <birunthan@mohanathas.com> | 2013-09-01 14:57:29 +0300 |
| commit | 30fc2c8df2fc565b20d8df3a202cb0c7d089afd0 (patch) | |
| tree | 42c9b28af8ee457d0ce351ede49b1bfa0feef19e /src/rt | |
| parent | 617850131b795312c4dd404ae7d853b54d883105 (diff) | |
| download | rust-30fc2c8df2fc565b20d8df3a202cb0c7d089afd0.tar.gz rust-30fc2c8df2fc565b20d8df3a202cb0c7d089afd0.zip | |
Fix incorrect strftime error handling in rust_localtime
Closes #8702.
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 9 |
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); |
