Bug 1360343 - ensure maskSurface is not null before dereference, since it can be null because of OOM or gfx device reset.

This commit is contained in:
Fedor 2019-05-20 09:02:04 +03:00
parent e26c5e1e50
commit 58d35590d4
2 changed files with 5 additions and 1 deletions

View File

@ -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<DataSourceSurface> GetDataSurface() override;

View File

@ -274,7 +274,8 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
}
RefPtr<DataSourceSurface> maskSurface = maskSnapshot->GetDataSurface();
DataSourceSurface::MappedSurface map;
if (!maskSurface->Map(DataSourceSurface::MapType::READ, &map)) {
if (!maskSurface ||
!maskSurface->Map(DataSourceSurface::MapType::READ, &map)) {
return nullptr;
}