From c0924842744fea67df49c9942b99d855b83578e5 Mon Sep 17 00:00:00 2001 From: Robbie Lyman Date: Fri, 7 Aug 2026 11:54:36 -0400 Subject: [PATCH] fix(Allocator): test leak --- lib/std/mem/Allocator.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); + } } } -- 2.54.0