[gegl/wip/Jehan/gimp-issue-6888: 30/30] operations: fix "fatal error: Floating point exception".




commit 2e1e4112d671ef60533be0a97aeaed67ad83badb
Author: Jehan <jehan girinstud io>
Date:   Sun Sep 5 20:13:42 2021 +0200

    operations: fix "fatal error: Floating point exception".
    
    div() expects integer arguments, and therefore any denominator less than
    1.0 gets rounded to 0, hence doing a division by 0.
    
    Instead remainder() works on double values, and anyway we only needed
    the remainder.
    
    See gimp#6888.
    Thanks to Massimo for reporting the source of the issue.

 operations/common-gpl3+/ripple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/operations/common-gpl3+/ripple.c b/operations/common-gpl3+/ripple.c
index 778709f69..8ecc76c4b 100644
--- a/operations/common-gpl3+/ripple.c
+++ b/operations/common-gpl3+/ripple.c
@@ -200,14 +200,14 @@ process (GeglOperation       *operation,
             switch (o->wave_type)
               {
                 case GEGL_RIPPLE_WAVE_TYPE_SAWTOOTH:
-                  lambda = div (nx + period / 2 - phi * period, period).rem;
+                  lambda = remainder (nx + period / 2 - phi * period, period);
                   if (lambda < 0)
                     lambda += period;
                   shift = amplitude * (((lambda / period) * 2) - 1);
                   break;
 
                 case GEGL_RIPPLE_WAVE_TYPE_TRIANGLE:
-                  lambda = div (nx + period * 3 / 4 - phi * period, period).rem;
+                  lambda = remainder (nx + period * 3 / 4 - phi * period, period);
                   if (lambda < 0)
                     lambda += period;
                   shift = amplitude * (fabs (((lambda / period) * 4) - 2) - 1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]