Skip to content

Commit c67f93e

Browse files
committed
delaunayn.m: Check inputs for non-finite values to avoid segfault in QHull (bug #67315)
* delaunayn.m: Validate that input PTS does not contain Inf or NaN using isfinite(). Update input validation message format to reflect Octave conventions. Update BIST tests for change of message. Add new BIST tests for bug #67315.
1 parent c3c3993 commit c67f93e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

scripts/geometry/delaunayn.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@
7070
7171
## NOTE: varargin options input validation is performed in __delaunayn__
7272
if ((! isnumeric (pts)) || (ndims (pts) > 2))
73-
error ("delaunayn: input PTS must be a 2-dimensional numeric array");
73+
error ("delaunayn: PTS must be a 2-dimensional numeric array");
74+
endif
75+
## QHull library will segfault if input contains Inf or NaN (bug #67315)
76+
if (any (! isfinite (pts(:))))
77+
error ("delaunayn: PTS must not contain Inf or NaN values");
7478
endif
7579

7680
## Perform delaunay calculation using either default or specified options
@@ -257,7 +261,9 @@
257261

258262
## Input validation tests
259263
%!error <Invalid call> delaunayn ()
260-
%!error <input PTS must be> delaunayn ("abc")
261-
%!error <input PTS must be> delaunayn ({1})
262-
%!error <input PTS must be> delaunayn (true)
263-
%!error <input PTS must be> delaunayn (ones (3,3,3))
264+
%!error <PTS must be .* numeric array> delaunayn ("abc")
265+
%!error <PTS must be .* numeric array> delaunayn ({1})
266+
%!error <PTS must be .* numeric array> delaunayn (true)
267+
%!error <PTS must be a 2-dimensional .* array> delaunayn (ones (3,3,3))
268+
%!error <PTS must not contain Inf> delaunayn ([1, Inf, 3])
269+
%!error <PTS must not contain .* NaN> delaunayn ([1, NaN, 3])

0 commit comments

Comments
 (0)