fuzz: add OSC parser fuzzer

This commit is contained in:
Mitchell Hashimoto
2026-03-03 08:31:05 -08:00
parent 2f0039d419
commit d2175d1b56
45 changed files with 100 additions and 28 deletions

View File

@@ -0,0 +1,26 @@
const std = @import("std");
/// Fixed-capacity allocator that avoids heap allocation and gives the
/// fuzzer deterministic, bounded memory behaviour. Backed by a single
/// fixed buffer; every `reset()` returns the bump pointer to the start
/// so the same memory is reused across iterations.
pub fn FuzzAllocator(comptime mem_size: usize) type {
return struct {
buf: [mem_size]u8 = undefined,
state: std.heap.FixedBufferAllocator = undefined,
const Self = @This();
pub fn init(self: *Self) void {
self.state = .init(&self.buf);
}
pub fn allocator(self: *Self) std.mem.Allocator {
return self.state.allocator();
}
pub fn reset(self: *Self) void {
self.state.reset();
}
};
}