Skip to content

Commit

Permalink
More reliable fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Jan 7, 2025
1 parent 4a1b11b commit dfe1953
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions fuzz/fuzz_targets/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,12 @@ impl<const D: usize> ArbitraryRay<D> {

// All components are zero or close to zero. Replace with a
// different vector so that `Ray::new` is able to normalize.
if direction.normalize().iter().any(|f| !f.is_finite()) {
//
// Uses !(a < b) instead of a >= b so that NaN results in true.
if !(direction.normalize().magnitude() - 1.0 < 0.1) {
direction[0] = 1.0;
}

// Make sure `Ray::new`'s normalization will succeed because, if it doesn't we would be fuzzing on
// invalid input.
assert!(
direction.normalize().magnitude() - 1.0 < 0.1,
"direction {} could not be normalized",
direction
);
let mut ray = Ray::new(self.origin.point(), direction);

if self.mode.is_grid() {
Expand Down

0 comments on commit dfe1953

Please sign in to comment.