Skip to content

Commit d68ae35

Browse files
committed
std: when a FixedBufferAllocator is initialised, set the buffer to undefined
1 parent da7880b commit d68ae35

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

std/heap.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ pub const FixedBufferAllocator = struct {
273273
buffer: []u8,
274274

275275
pub fn init(buffer: []u8) FixedBufferAllocator {
276+
// This loop gets optimized out in ReleaseFast mode
277+
for (buffer) |*byte| {
278+
byte.* = undefined;
279+
}
276280
return FixedBufferAllocator{
277281
.allocator = Allocator{
278282
.allocFn = alloc,

0 commit comments

Comments
 (0)