| ... | @@ -141,8 +141,8 @@ pub const DirectAllocator = struct { | ... | @@ -141,8 +141,8 @@ pub const DirectAllocator = struct { |
| 141 | return shrink(allocator, old_mem, old_align, new_size, new_align); | 141 | return shrink(allocator, old_mem, old_align, new_size, new_align); |
| 142 | } | 142 | } |
| 143 | const result = try alloc(allocator, new_size, new_align); | 143 | const result = try alloc(allocator, new_size, new_align); |
| 144 | @memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len)); | 144 | if (old_mem.len != 0) { |
| 145 | if (old_mem.len > 0) { | 145 | @memcpy(result.ptr, old_mem.ptr, std.math.min(old_mem.len, result.len)); |
| 146 | _ = os.posix.munmap(@ptrToInt(old_mem.ptr), old_mem.len); | 146 | _ = os.posix.munmap(@ptrToInt(old_mem.ptr), old_mem.len); |
| 147 | } | 147 | } |
| 148 | return result; | 148 | return result; |