Potential division-by-zero at spline.c
Brought to you by:
mennucc,
mijagourlay
Dear authors,
There exists a potential division-by-zero at the function hermite3_interp
in libmorph/spline.c
...
281 h = x[si+1] - x[si];
282 h_2 = h*h;
...
338 A = (y[si+1] - y[si] - h*d[si])/h_2;
339 B = (d[si+1] - d[si] - 2.0*h*A)/h_2;
, when arbitary values are given to x[si+1]
and x[si]
from
DrawMeshes
function in diw_map.c
347 diw_map_t * diw_mapP = diw_map_of_widget(widget)
while
diw_map.c
in diw_map_of_widget
returns
302 global_diw_map[indx].mesh_dst.y = global_diw_map[0].mesh_dst.y;
...
317 dmP = &global_diw_map[indx];
...
320 retrun dmP
and global_diw_map is read from
initialize_application
function in xmorph.c
432 meshRead(&global_diw_map[0].mesh_dst, dstmesh)
A simple possible fix suggestion would be adding additional if statements.
For example,
+ if (!h_2) return 0;
338 A = (y[si+1] - y[si] - h*d[si])/h_2;
Yeah, your suggestion looks legit. Thanks!
I haven't touched this code in a few decades. I'm glad you're finding some utility from it!