Skip to content

Commit 52a13f6

Browse files
committed
web ui: fix not sending initial context sometimes
This would cause the web ui to crash in js or wasm.
1 parent 2da8ec9 commit 52a13f6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/std/Build/Fuzz.zig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,12 @@ pub fn serveSourcesTar(fuzz: *Fuzz, req: *std.http.Server.Request) !void {
257257
pub const Previous = struct {
258258
unique_runs: usize,
259259
entry_points: usize,
260-
pub const init: Previous = .{ .unique_runs = 0, .entry_points = 0 };
260+
sent_source_index: bool,
261+
pub const init: Previous = .{
262+
.unique_runs = 0,
263+
.entry_points = 0,
264+
.sent_source_index = false,
265+
};
261266
};
262267
pub fn sendUpdate(
263268
fuzz: *Fuzz,
@@ -280,7 +285,8 @@ pub fn sendUpdate(
280285
const n_runs = @atomicLoad(usize, &cov_header.n_runs, .monotonic);
281286
const unique_runs = @atomicLoad(usize, &cov_header.unique_runs, .monotonic);
282287
{
283-
if (unique_runs != 0 and prev.unique_runs == 0) {
288+
if (!prev.sent_source_index) {
289+
prev.sent_source_index = true;
284290
// We need to send initial context.
285291
const header: abi.SourceIndexHeader = .{
286292
.directories_len = @intCast(coverage_map.coverage.directories.entries.len),

0 commit comments

Comments
 (0)