diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index d50c7c1764bfe5b38a78d0761bb4983736839e41..98164b5b21abf095f3c65c9cd0abebe21b00193d 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -627,7 +627,10 @@ test "free single-pointer to array" { const allocation = try allocator.alloc(u32, 128); allocation[127] = 0; const ptr: *[127:0]u32 = allocation[0..127 :0]; - const new = try allocator.realloc(ptr, 16); - allocator.free(new); + if (allocator.realloc(ptr, 16)) |new| { + allocator.free(new); + } else |_| { + allocator.free(allocation); + } } }