commit dfa8b661b506a463a669754ed635b0a8eb67580e Author: Thomas Loimer Date: Thu Apr 10 09:03:30 2025 +0200 Detect nan in spline control values, ticket #192 --- fig2dev/read.c | 17 +++++++++++------ fig2dev/tests/read.at | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) --- fig2dev/read.c +++ fig2dev/read.c 2025-05-16 08:04:13.646999235 +0000 @@ -1581,12 +1581,17 @@ read_splineobject(FILE *fp, char **restr free_splinestorage(s); return NULL; } - if (lx < INT_MIN || lx > INT_MAX || ly < INT_MIN || - ly > INT_MAX || rx < INT_MIN || rx > INT_MAX || - ry < INT_MIN || ry > INT_MAX) { - /* do not care to clean up, we exit anyway - cp->next = NULL; - free_splinestorage(s); */ + if ( !isfinite(lx) || lx < INT_MIN || lx > INT_MAX || + !isfinite(ly) || ly < INT_MIN || ly > INT_MAX || + !isfinite(rx) || rx < INT_MIN || rx > INT_MAX || + !isfinite(ry) || ry < INT_MIN || ry > INT_MAX) + { + + /* clean up, to pass test "reject huge spline controls + values" when -fsanitize=address is enabled */ + cp->next = NULL; + free_splinestorage(s); + free(cq); put_msg("Spline control points out of range " "at line %d.", *line_no); exit(EXIT_FAILURE); --- fig2dev/tests/read.at +++ fig2dev/tests/read.at 2025-05-16 08:07:33.111333617 +0000 @@ -608,6 +608,25 @@ EOF ]) AT_CLEANUP +AT_SETUP([reject nan in spline controls values, #192]) +AT_KEYWORDS([read.c]) +# Use an output language that does not natively support Bezier splines. +# Otherwise, the huge values are simply copied to the output. +AT_CHECK([fig2dev -L epic <