authorgravatar for goon.pri.low@gmail.comKendall Condon <goon.pri.low@gmail.com> 2026-03-11 20:23:23-04:00
committergravatar for goon.pri.low@gmail.comKendall Condon <goon.pri.low@gmail.com> 2026-03-11 20:23:23-04:00
logc3a417206a6780393dae871a351fb9617012aee2
treeb337bf840ed0da170b9b54a4d61a61d44daa7b97
parentb4ffb402c082605c4b324e88120306fc8fb3cf32

libfuzzer: check weights for bytes mutations


1 files changed, 16 insertions(+), 6 deletions(-)

lib/fuzzer.zig+16-6
......@@ -1320,13 +1320,23 @@ const Fuzzer = struct {
13201320
13211321 if (opts.copy != 0) {
13221322 if (opts.fresh == 0 or slice_i == data_slice.len) return .fresh;
1323 return .{ .mutate = switch (uid.kind) {
1324 .int => .{ .int = data.ints[data_i] },
1325 .bytes => .{ .bytes = b: {
1323 switch (uid.kind) {
1324 .int => {
1325 const int = data.ints[data_i];
1326 if (weightsContain(int, weights)) {
1327 @branchHint(.likely);
1328 return .{ .mutate = .{ .int = int } };
1329 }
1330 },
1331 .bytes => {
13261332 const entry = data.bytes.entries[data_i];
1327 break :b data.bytes.table[entry.off..][0..entry.len];
1328 } },
1329 } };
1333 const bytes = data.bytes.table[entry.off..][0..entry.len];
1334 if (weightsContainBytes(bytes, weights)) {
1335 @branchHint(.likely);
1336 return .{ .mutate = .{ .bytes = bytes } };
1337 }
1338 },
1339 }
13301340 }
13311341
13321342 if (!opts.splice) {