Bug 1318007: When the surface is already allocated, just check for non-positive dimensions. r?aosmond
MozReview-Commit-ID: C0Fkq1SVO3s
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -765,17 +765,20 @@ Factory::CreateSourceSurfaceForCairoSurf
already_AddRefed<DataSourceSurface>
Factory::CreateWrappingDataSourceSurface(uint8_t *aData,
int32_t aStride,
const IntSize &aSize,
SurfaceFormat aFormat,
SourceSurfaceDeallocator aDeallocator /* = nullptr */,
void* aClosure /* = nullptr */)
{
- if (!AllowedSurfaceSize(aSize)) {
+ // Just check for negative/zero size instead of the full AllowedSurfaceSize() - since
+ // the data is already allocated we do not need to check for a possible overflow - it
+ // already worked.
+ if (aSize.width <= 0 || aSize.height <= 0) {
return nullptr;
}
if (!aDeallocator && aClosure) {
return nullptr;
}
MOZ_ASSERT(aData);