[poppler] poppler/GfxState.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 19 20:53:25 UTC 2020


 poppler/GfxState.cc |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 2c353300b65f3a89ddb9377a4ef8864bff8d49ab
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Nov 19 21:27:30 2020 +0100

    GfxLabColorSpace::parse: Protect against division by 0
    
    oss-fuzz/27619

diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index eaf96dba..85c4a2b6 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -1387,9 +1387,16 @@ GfxColorSpace *GfxLabColorSpace::parse(Array *arr, GfxState *state)
         return nullptr;
     }
 
-    cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX + xyzrgb[0][1] * cs->whiteY + xyzrgb[0][2] * cs->whiteZ);
-    cs->kg = 1 / (xyzrgb[1][0] * cs->whiteX + xyzrgb[1][1] * cs->whiteY + xyzrgb[1][2] * cs->whiteZ);
-    cs->kb = 1 / (xyzrgb[2][0] * cs->whiteX + xyzrgb[2][1] * cs->whiteY + xyzrgb[2][2] * cs->whiteZ);
+    const auto krDenominator = (xyzrgb[0][0] * cs->whiteX + xyzrgb[0][1] * cs->whiteY + xyzrgb[0][2] * cs->whiteZ);
+    const auto kgDenominator = (xyzrgb[1][0] * cs->whiteX + xyzrgb[1][1] * cs->whiteY + xyzrgb[1][2] * cs->whiteZ);
+    const auto kbDenominator = (xyzrgb[2][0] * cs->whiteX + xyzrgb[2][1] * cs->whiteY + xyzrgb[2][2] * cs->whiteZ);
+    if (unlikely(krDenominator == 0 || kgDenominator == 0 || kbDenominator == 0)) {
+        delete cs;
+        return nullptr;
+    }
+    cs->kr = 1 / krDenominator;
+    cs->kg = 1 / kgDenominator;
+    cs->kb = 1 / kbDenominator;
 
 #ifdef USE_CMS
     cs->transform = (state != nullptr) ? state->getXYZ2DisplayTransform() : nullptr;


More information about the poppler mailing list