about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libextra/time.rs5
-rw-r--r--src/rt/rust_builtin.cpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/libextra/time.rs b/src/libextra/time.rs
index 257d941e4af..6119170f130 100644
--- a/src/libextra/time.rs
+++ b/src/libextra/time.rs
@@ -121,6 +121,9 @@ pub struct Tm {
 }
 
 pub fn empty_tm() -> Tm {
+    // 64 is the max size of the timezone buffer allocated on windows
+    // in rust_localtime. In glibc the max timezone size is supposedly 3.
+    let zone = str::with_capacity(64);
     Tm {
         tm_sec: 0_i32,
         tm_min: 0_i32,
@@ -132,7 +135,7 @@ pub fn empty_tm() -> Tm {
         tm_yday: 0_i32,
         tm_isdst: 0_i32,
         tm_gmtoff: 0_i32,
-        tm_zone: ~"",
+        tm_zone: zone,
         tm_nsec: 0_i32,
     }
 }
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index de86035b632..d7cb0296a17 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -292,7 +292,7 @@ void tm_to_rust_tm(tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
 
     if (zone != NULL) {
         size_t size = strlen(zone);
-        reserve_vec_exact(&out_tm->tm_zone, size);
+        assert(out_tm->tm_zone->alloc >= size);
         memcpy(out_tm->tm_zone->data, zone, size);
         out_tm->tm_zone->fill = size;
     }