From 2463d5dfdf1ece466f38b6cd57044dec4caa5b57 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Wed, 6 Sep 2023 11:44:21 +0200 Subject: limit samples to only non zero positive numbers This fixes a bug with too high scales causing a division by zero --- src/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 6d37dc8..7c9a161 100644 --- a/src/main.c +++ b/src/main.c @@ -58,8 +58,11 @@ static uint32_t average(const uint32_t dest, const uint32_t src) } static void scale_image(const uint32_t* input, const signed input_width, const signed input_height, - uint32_t* output, const double multiplier, const signed samples) + uint32_t* output, const double multiplier, signed samples) { + if (samples <= 0) + samples = 1; + signed output_width = input_width * multiplier; uint32_t pixel; -- cgit v1.2.3