[babl] babl: avoid negative degree when shrinking a zero polynomial



commit 47a86a1a20b6289cfe11d993e0f381b6b5970449
Author: Ell <ell_se yahoo com>
Date:   Sun Sep 24 13:43:02 2017 -0400

    babl: avoid negative degree when shrinking a zero polynomial
    
    When shrinking a zero polynomial, avoid trying to set its degree
    to a negative value, and just keep it at 0, which is the minimal
    degree we support.
    
    Note that this also happens for polynomials whose coefficients are
    all NaN, as is the case in bug 788093, so they also become zero
    polynomials after shrinking, incidentally.

 babl/babl-polynomial.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/babl/babl-polynomial.c b/babl/babl-polynomial.c
index d51685d..c9f195b 100644
--- a/babl/babl-polynomial.c
+++ b/babl/babl-polynomial.c
@@ -190,7 +190,11 @@ babl_polynomial_shrink (BablPolynomial *poly)
         break;
     }
 
-  if (i > 0)
+  if (i == poly->degree + 1)
+    {
+      babl_polynomial_reset (poly, poly->scale);
+    }
+  else if (i > 0)
     {
       memmove (poly->coeff, &poly->coeff[i],
                (poly->degree - i + 1) * sizeof (double));


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