Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mm2/Little-CMS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <marti.maria@littlecms.com>2022-08-11 18:39:45 +0300
committerMarti Maria <marti.maria@littlecms.com>2022-08-11 18:39:45 +0300
commit80a994685f6507e8d0cdbc69822ab0700e301810 (patch)
tree788b58f304465a7c7dd663646fced1008b035d22
parentc67fbeafe18565177565448f97f3334866fca94b (diff)
add check for divide by zero
Check for corrupted profiles
-rw-r--r--src/cmssamp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cmssamp.c b/src/cmssamp.c
index 463de69..f5957d1 100644
--- a/src/cmssamp.c
+++ b/src/cmssamp.c
@@ -323,6 +323,7 @@ cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[]
if (fabs(a) < 1.0E-10) {
+ if (fabs(b) < 1.0E-10) return 0;
return cmsmin(0, cmsmax(50, -c/b ));
}
else {
@@ -333,7 +334,11 @@ cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[]
}
else {
- double rt = (-b + sqrt(d)) / (2.0 * a);
+ double rt;
+
+ if (fabs(a) < 1.0E-10) return 0;
+
+ rt = (-b + sqrt(d)) / (2.0 * a);
return cmsmax(0, cmsmin(50, rt));
}