Resolves: tdf#131507 createCairoSurface returns nullptr on failure
Change-Id: I05190a6f280ebbe750dfda56ef27d3362222b95f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90940
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 6a5a7a2..4f80ae3 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -374,7 +374,7 @@ namespace
unsigned long nTargetWidth = 0,
unsigned long nTargetHeight = 0) const
{
if(bDisableDownScale || 0 == nTargetWidth || 0 == nTargetHeight || isTrivial())
if (bDisableDownScale || 0 == nTargetWidth || 0 == nTargetHeight || !pSurface || isTrivial())
{
// caller asks for original or disabled or trivial (smaller then a minimal square size)
// also excludes zero cases for width/height after this point if need to prescale