From f665e4cfa91facf38970d93f9e8e835e6ea1734d Mon Sep 17 00:00:00 2001 From: Pedro Gimeno Date: Sun, 29 May 2016 00:13:22 +0200 Subject: [PATCH] Bug 738951 - (modulo n m) may fail for m >= 46342 (in 32-bit) or m >= 3037000501 (in 64-bit) --- plug-ins/script-fu/tinyscheme/scheme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plug-ins/script-fu/tinyscheme/scheme.c b/plug-ins/script-fu/tinyscheme/scheme.c index 06137db230..86b02fe1f8 100644 --- a/plug-ins/script-fu/tinyscheme/scheme.c +++ b/plug-ins/script-fu/tinyscheme/scheme.c @@ -498,7 +498,7 @@ static num num_rem(num a, num b) { e1=num_ivalue(a); e2=num_ivalue(b); res=e1%e2; - /* remainder should have same sign as second operand */ + /* remainder should have same sign as first operand */ if (res > 0) { if (e1 < 0) { res -= labs(e2); @@ -520,7 +520,7 @@ static num num_mod(num a, num b) { e2=num_ivalue(b); res=e1%e2; /* modulo should have same sign as second operand */ - if (res * e2 < 0) { + if ((res < 0) != (e2 < 0) && res) { /* if their sign is different... */ res+=e2; } ret.value.ivalue=res;