Skip to content

Commit 4ce7d57

Browse files
committed
auto merge of #10348 : ksh8281/rust/fix_android_timegm, r=yichoi
fix timegm bug on android TZ restore not correctly before. and it cause test case fail (time::tests::run_tests::test_convertions) with @sammykim
2 parents 35c3aaf + 09257df commit 4ce7d57

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/rt/rust_builtin.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ timegm(struct tm *tm)
4343
char *tz;
4444

4545
tz = getenv("TZ");
46+
if (tz)
47+
tz = strdup(tz);
4648
setenv("TZ", "", 1);
4749
tzset();
4850
ret = mktime(tm);
49-
if (tz)
51+
if (tz) {
5052
setenv("TZ", tz, 1);
51-
else
53+
free(tz);
54+
} else
5255
unsetenv("TZ");
5356
tzset();
5457
return ret;

0 commit comments

Comments
 (0)