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

MozReview-Commit-ID: HX2qsWLZpMg

--HG--
extra : rebase_source : 046befc11151461a682842c31e2ce39247a5e1d8
This commit is contained in:
cku 2017-04-28 11:48:21 +08:00 committed by Roy Tam
commit f9ae2860ab
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;
}