From 7b1085472925b587184d2ea07f717a04eb45efcb Mon Sep 17 00:00:00 2001 From: tTh Date: Mon, 18 Sep 2023 15:29:40 +0200 Subject: [PATCH] add a zerodivide mollyguard --- Lib/patterns4.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/patterns4.c b/Lib/patterns4.c index 0c4a900..5afcc9a 100644 --- a/Lib/patterns4.c +++ b/Lib/patterns4.c @@ -23,6 +23,12 @@ int x, y, v, delta; delta = high - low; +if (0 == delta) { + fprintf(stderr, "%s: bad low/high parameters %d %d <- delta is 0\n", + __func__, low, high); + return DIVISOR_IS_ZERO; + } + for (x=0; xwidth; x++) { for (y=0; yheight; y++) @@ -44,6 +50,12 @@ int x, y, r, g, b, delta; delta = high - low; +if (0 == delta) { + fprintf(stderr, "%s: bad low/high parameters %d %d <- delta is 0\n", + __func__, low, high); + return DIVISOR_IS_ZERO; + } + for (x=0; xwidth; x++) { for (y=0; yheight; y++)