Skip to content

Commit c70486f

Browse files
committed
auto merge of #8913 : poiru/rust/issue-8702, r=cmr
Closes #8702.
2 parents 7c5398b + 30fc2c8 commit c70486f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/rt/rust_builtin.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,16 @@ rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
321321
time_t s = sec;
322322
LOCALTIME(&s, &tm);
323323

324+
const char* zone = NULL;
324325
#if defined(__WIN32__)
325326
int32_t gmtoff = -timezone;
326-
char zone[64];
327-
strftime(zone, sizeof(zone), "%Z", &tm);
327+
char buffer[64];
328+
if (strftime(buffer, sizeof(buffer), "%Z", &tm) > 0) {
329+
zone = buffer;
330+
}
328331
#else
329332
int32_t gmtoff = tm.tm_gmtoff;
330-
const char *zone = tm.tm_zone;
333+
zone = tm.tm_zone;
331334
#endif
332335

333336
tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);

0 commit comments

Comments
 (0)