summaryrefslogtreecommitdiff
path: root/drawinglayer/source/processor2d
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-10-06 16:24:16 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-10-06 21:58:45 +0200
commit5e1eaea2729c0e51eef6ede7d54601573cff638e (patch)
tree7d8f270e67a7ecde15c380d2aa0ec1b5309fac42 /drawinglayer/source/processor2d
parentf60d768fad73494fbfd600d8c7f8a0f1c7e3e857 (diff)
crashtesting: avoid null deref on failure of cairo_image_surface_create
seen since: commit 1acd37a671b9d3633a7d31a0b60478815fbc685f CommitDate: Mon Sep 23 14:12:04 2024 +0200 CairoSDPR: Activate globally to check builds/tests Change-Id: If3068b436eb57b48b048d30538b71563f38735d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174561 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'drawinglayer/source/processor2d')
-rw-r--r--drawinglayer/source/processor2d/cairopixelprocessor2d.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx
index 06e1459d1b4c..365d62a19fc6 100644
--- a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx
@@ -419,6 +419,12 @@ class CairoSurfaceHelper
const tools::Long nHeight(pReadAccess->Height());
const tools::Long nWidth(pReadAccess->Width());
mpCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
+ if (cairo_surface_status(mpCairoSurface) != CAIRO_STATUS_SUCCESS)
+ {
+ SAL_WARN("drawinglayer",
+ "cairo_image_surface_create failed for: " << nWidth << " x " << nHeight);
+ return;
+ }
const sal_uInt32 nStride(cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nWidth));
unsigned char* surfaceData(cairo_image_surface_get_data(mpCairoSurface));
@@ -450,6 +456,12 @@ class CairoSurfaceHelper
const tools::Long nHeight(pReadAccess->Height());
const tools::Long nWidth(pReadAccess->Width());
mpCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, nWidth, nHeight);
+ if (cairo_surface_status(mpCairoSurface) != CAIRO_STATUS_SUCCESS)
+ {
+ SAL_WARN("drawinglayer",
+ "cairo_image_surface_create failed for: " << nWidth << " x " << nHeight);
+ return;
+ }
sal_uInt32 nStride(cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, nWidth));
unsigned char* surfaceData(cairo_image_surface_get_data(mpCairoSurface));
@@ -481,6 +493,12 @@ class CairoSurfaceHelper
const tools::Long nHeight(pReadAccess->Height());
const tools::Long nWidth(pReadAccess->Width());
mpCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_RGB16_565, nWidth, nHeight);
+ if (cairo_surface_status(mpCairoSurface) != CAIRO_STATUS_SUCCESS)
+ {
+ SAL_WARN("drawinglayer",
+ "cairo_image_surface_create failed for: " << nWidth << " x " << nHeight);
+ return;
+ }
sal_uInt32 nStride(cairo_format_stride_for_width(CAIRO_FORMAT_RGB16_565, nWidth));
unsigned char* surfaceData(cairo_image_surface_get_data(mpCairoSurface));