seamoptimizer icon indicating copy to clipboard operation
seamoptimizer copied to clipboard

Check for a divide by zero in the step calculation

Open expenses opened this issue 2 years ago • 0 comments

Hi, thanks for the great library! I'm still evaluating if it'll work for my needs but I managed to find one SEGFAULT along the way.

float l = so_length2(ad);
int iterations = (int)(l * 5.0f); // TODO: is this the best value?
float step = 1.0f / iterations;

with this code, if l is below 0.2 (0.1995 or so in my case) then the number of iterations will be 0 and step will be nan, which breaks things down the chain and ends up with an attempt to read an out of bounds value from the lightmap.

expenses avatar Jan 31 '23 11:01 expenses