fix: don't crash when seeing -1 in code cov (#11131)

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
dave caruso
2024-05-17 15:53:19 -07:00
committed by GitHub
parent 902c258c1b
commit 4e714ae9dc
2 changed files with 24 additions and 0 deletions

View File

@@ -394,6 +394,8 @@ pub const ByteRangeMapping = struct {
executable_lines = try Bitset.initEmpty(allocator, line_count);
lines_which_have_executed = try Bitset.initEmpty(allocator, line_count);
for (blocks, 0..) |block, i| {
if (block.endOffset < 0) continue; // does not map to anything
const min: usize = @intCast(@min(block.startOffset, block.endOffset));
const max: usize = @intCast(@max(block.startOffset, block.endOffset));
var min_line: u32 = std.math.maxInt(u32);
@@ -473,6 +475,8 @@ pub const ByteRangeMapping = struct {
lines_which_have_executed = try Bitset.initEmpty(allocator, line_count);
for (blocks, 0..) |block, i| {
if (block.endOffset < 0) continue; // does not map to anything
const min: usize = @intCast(@min(block.startOffset, block.endOffset));
const max: usize = @intCast(@max(block.startOffset, block.endOffset));
var min_line: u32 = std.math.maxInt(u32);