Skip to content

Commit 76deb2a

Browse files
authored
Prevent dereferencing of a null pointer (#59)
In lines 2078 and 2085, `intersect_line_with_segment` is intentionally called with `0` as the fifth argument.
1 parent 21aff7e commit 76deb2a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

utils/geom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,11 +1977,11 @@ int intersect_line_with_segment(vector3 q0, vector3 q1, vector3 q2, vector3 u, d
19771977
if (fabs(dot) < (1.0 - THRESH) * q01 * q02)
19781978
return NON_INTERSECTING;
19791979
else if (dot < 0.0) {
1980-
*s = 0.0;
1980+
if (s) *s = 0.0;
19811981
return IN_SEGMENT;
19821982
}
19831983
else if ((u.x * q01x + u.y * q01y) < 0.0) {
1984-
*s = fmin(q01, q02) / sqrt(u.x * u.x + u.y * u.y);
1984+
if (s) *s = fmin(q01, q02) / sqrt(u.x * u.x + u.y * u.y);
19851985
return ON_RAY;
19861986
}
19871987
return NON_INTERSECTING;

0 commit comments

Comments
 (0)