From 0a673e8fb888ef0ce74a1f6cc608924188c2776b Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Tue, 31 Jan 2023 12:46:46 +0100 Subject: [PATCH] Check for a divide by zero in the step calculation --- seamoptimizer.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seamoptimizer.h b/seamoptimizer.h index 1ec4911..19847dd 100644 --- a/seamoptimizer.h +++ b/seamoptimizer.h @@ -466,6 +466,10 @@ static void so_seams_add_seam(so_seam_t **seams, so_vec2 a0, so_vec2 a1, so_vec2 int iterations = (int)(l * 5.0f); // TODO: is this the best value? float step = 1.0f / iterations; + if (iterations == 0) { + step = 0.0; + } + so_seam_t currentSeam = {0}; currentSeam.x_min = w; currentSeam.y_min = h; currentSeam.x_max = 0; currentSeam.y_max = 0;