aboutsummaryrefslogtreecommitdiff
path: root/lib/std/heap.zig
diff options
context:
space:
mode:
authorJonathan Marler <johnnymarler@gmail.com>2020-06-28 14:33:41 -0600
committerAndrew Kelley <andrew@ziglang.org>2020-06-28 18:05:18 -0400
commitc2eead9629b60a394aa61e6f96b89647eddce1ea (patch)
treea14ec292715a2ceb0cd9b8d018eee58449230256 /lib/std/heap.zig
parent374e3e42e0de10d21406c077599cfc4a6a813497 (diff)
downloadzig-c2eead9629b60a394aa61e6f96b89647eddce1ea.tar.gz
zig-c2eead9629b60a394aa61e6f96b89647eddce1ea.zip
Fix issue 5741, use after free
Diffstat (limited to 'lib/std/heap.zig')
-rw-r--r--lib/std/heap.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/std/heap.zig b/lib/std/heap.zig
index 260841ad2d..ea9e95c675 100644
--- a/lib/std/heap.zig
+++ b/lib/std/heap.zig
@@ -714,6 +714,11 @@ test "PageAllocator" {
slice[127] = 0x34;
allocator.free(slice);
}
+ {
+ var buf = try allocator.alloc(u8, mem.page_size + 1);
+ defer allocator.free(buf);
+ buf = try allocator.realloc(buf, 1); // shrink past the page boundary
+ }
}
test "HeapAllocator" {