diff --git a/std/heap.zig b/std/heap.zig index 84ed469763..dd5cfa4cd7 100644 --- a/std/heap.zig +++ b/std/heap.zig @@ -143,8 +143,9 @@ pub const DirectAllocator = struct { return result; }, Os.windows => { - const self = @fieldParentPtr(DirectAllocator, "allocator", allocator); + if (old_mem.len == 0) return alloc(allocator, new_size, new_align); + const self = @fieldParentPtr(DirectAllocator, "allocator", allocator); const old_adjusted_addr = @ptrToInt(old_mem.ptr); const old_record_addr = old_adjusted_addr + old_mem.len; const root_addr = @intToPtr(*align(1) usize, old_record_addr).*; diff --git a/std/os/windows/util.zig b/std/os/windows/util.zig index 24039967a1..72c84502e3 100644 --- a/std/os/windows/util.zig +++ b/std/os/windows/util.zig @@ -197,7 +197,7 @@ pub fn createWindowsEnvBlock(allocator: *mem.Allocator, env_map: *const BufMap) i += 1; result[i] = 0; i += 1; - return allocator.shrink(u16, result, i); + return allocator.shrink(result, i); } pub fn windowsFindFirstFile(