summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/dng_color_spec.cpp12
-rw-r--r--source/dng_render.cpp6
2 files changed, 15 insertions, 3 deletions
diff --git a/source/dng_color_spec.cpp b/source/dng_color_spec.cpp
index 139cdee..807ee4d 100644
--- a/source/dng_color_spec.cpp
+++ b/source/dng_color_spec.cpp
@@ -409,8 +409,12 @@ void dng_color_spec::SetWhiteXY (const dng_xy_coord &white)
// Find the camera white values.
fCameraWhite = colorMatrix * XYtoXYZ (fWhiteXY);
-
- real64 whiteScale = 1.0 / MaxEntry (fCameraWhite);
+ real64 cameraWhiteMaxEntry = MaxEntry (fCameraWhite);
+ if (cameraWhiteMaxEntry == 0)
+ {
+ ThrowBadFormat ();
+ }
+ real64 whiteScale = 1.0 / cameraWhiteMaxEntry;
for (uint32 j = 0; j < fChannels; j++)
{
@@ -430,6 +434,10 @@ void dng_color_spec::SetWhiteXY (const dng_xy_coord &white)
real64 scale = MaxEntry (fPCStoCamera * PCStoXYZ ());
+ if (scale == 0)
+ {
+ ThrowBadFormat ();
+ }
fPCStoCamera = (1.0 / scale) * fPCStoCamera;
// If we have a forward matrix, then just use that.
diff --git a/source/dng_render.cpp b/source/dng_render.cpp
index bd8d0f8..e3d9940 100644
--- a/source/dng_render.cpp
+++ b/source/dng_render.cpp
@@ -34,13 +34,17 @@ dng_function_exposure_ramp::dng_function_exposure_ramp (real64 white,
real64 black,
real64 minBlack)
- : fSlope ((white == black) ? 1.0f : 1.0 / (white - black))
+ : fSlope ((white == black) ? 0.0f : 1.0 / (white - black))
, fBlack (black)
, fRadius (0.0)
, fQScale (0.0)
{
+ if (fSlope == 0.0)
+ {
+ ThrowBadFormat ();
+ }
const real64 kMaxCurveX = 0.5; // Fraction of minBlack.