From 10353416c9a6d6a92281d83c6ee20af4962889a3 Mon Sep 17 00:00:00 2001 From: Ingo Date: Mon, 24 Mar 2014 16:30:41 +0100 Subject: [PATCH] Fixed two possible reasons for nan values, Issue 2194 --- rtengine/curves.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rtengine/curves.h b/rtengine/curves.h index f5bc56359..1d0661ae2 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -171,9 +171,14 @@ class CurveFactory { { if (comp>0.0) { float val = level+(hlrange-65536.0); + if(val == 0.0f) // to avoid division by zero + val = 0.000001f; float Y = val*exp_scale/hlrange; + Y *= comp; + if(Y <= -1.0) // to avoid log(<=0) + Y = -.999999f; float R = hlrange/(val*comp); - return log(1.0+Y*comp)*R; + return log(1.0+Y)*R; } else { return exp_scale; }