From 58d35590d41ad5ade1c008582eaf31723851f0b1 Mon Sep 17 00:00:00 2001 From: Fedor Date: Mon, 20 May 2019 09:02:04 +0300 Subject: [PATCH] Bug 1360343 - ensure maskSurface is not null before dereference, since it can be null because of OOM or gfx device reset. --- gfx/2d/2D.h | 3 +++ layout/svg/nsSVGMaskFrame.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index c1fba3463..e2020dc9e 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -488,6 +488,9 @@ public: /** * Returns a DataSourceSurface with the same data as this one, but * guaranteed to have surface->GetType() == SurfaceType::DATA. + * + * The returning surface might be null, because of OOM or gfx device reset. + * The caller needs to do null-check before using it. */ virtual already_AddRefed GetDataSurface() override; diff --git a/layout/svg/nsSVGMaskFrame.cpp b/layout/svg/nsSVGMaskFrame.cpp index b8e4b32ae..a22833d61 100644 --- a/layout/svg/nsSVGMaskFrame.cpp +++ b/layout/svg/nsSVGMaskFrame.cpp @@ -274,7 +274,8 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext, } RefPtr maskSurface = maskSnapshot->GetDataSurface(); DataSourceSurface::MappedSurface map; - if (!maskSurface->Map(DataSourceSurface::MapType::READ, &map)) { + if (!maskSurface || + !maskSurface->Map(DataSourceSurface::MapType::READ, &map)) { return nullptr; }