Skip to content

Commit a2a0de3

Browse files
committed
fix(profiling): fuzz test assumption about mapping_id=0
1 parent 87bcfbd commit a2a0de3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

profiling/src/internal/profile/fuzz_tests.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ fn assert_samples_eq(
277277
// `small_non_zero_pprof_id()` function which guarantees that the id stored in pprof
278278
// is +1 of the index in the vector of Locations in internal::Profile.
279279
let location = &profile.locations[*loc_id as usize - 1];
280-
let mapping = &profile.mappings[location.mapping_id as usize - 1];
280+
281+
// PHP, Python, and Ruby don't use mappings, so allow for zero id.
282+
let mapping = if location.mapping_id != 0 {
283+
profile.mappings[location.mapping_id as usize - 1]
284+
} else {
285+
Default::default()
286+
};
281287
// internal::Location::to_pprof() always creates a single line.
282288
assert!(location.lines.len() == 1);
283289
let line = location.lines[0];

0 commit comments

Comments
 (0)