oox/source/export/drawingml.cxx |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit f412c1e448b0268294ccbccee4f3a6a9e76a7b98
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Tue Jun 13 14:37:56 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Jun 13 16:55:07 2023 +0200

    cid#1532377 Dereference before null check
    
    Change-Id: Ie85e81cea63578413db2c69020dae6a105466cb4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152963
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 5b0772550471..dca260895af8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -761,6 +761,14 @@ void DrawingML::WriteGradientFill(
         basegfx::utils::prepareColorStops(*pTransparenceGradient, aAlphaStops, 
aSingleAlpha);
     }
 
+    if (nullptr == pGradient)
+    {
+        // an error - see comment in header - is to give neither pColorGradient
+        // nor pTransparenceGradient
+        assert(false && "pColorGradient or pTransparenceGradient should be 
set");
+        return;
+    }
+
     // apply steps if used. Need to do that before synchronizeColorStops
     // since that may add e.g. for AlphaStops all-the-same no-data entries,
     // so the number of entries might change
@@ -775,12 +783,10 @@ void DrawingML::WriteGradientFill(
     // method (at import time) will be exported again
     basegfx::utils::synchronizeColorStops(aColorStops, aAlphaStops, 
aSingleColor, aSingleAlpha);
 
-    if (aColorStops.size() != aAlphaStops.size() || nullptr == pGradient)
+    if (aColorStops.size() != aAlphaStops.size())
     {
         // this is an error - synchronizeColorStops above *has* to create that
         // state, see description there (!)
-        // also an error - see comment in header - is to give neither 
pColorGradient
-        // nor pTransparenceGradient
         assert(false && "oox::WriteGradientFill: non-synchronized gradients 
(!)");
         return;
     }

Reply via email to