diff options
| -rw-r--r-- | src/rt/rust_builtin.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index e8141d37ff1..387948613e1 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -43,12 +43,15 @@ timegm(struct tm *tm) char *tz; tz = getenv("TZ"); + if (tz) + tz = strdup(tz); setenv("TZ", "", 1); tzset(); ret = mktime(tm); - if (tz) + if (tz) { setenv("TZ", tz, 1); - else + free(tz); + } else unsetenv("TZ"); tzset(); return ret; |
