Bug 1318007: When the surface is already allocated, just check for non-positive dimensions. r?aosmond draft
authorMilan Sreckovic <milan@mozilla.com>
Mon, 21 Nov 2016 12:48:40 -0500
changeset 442085 fdac3e02c07f9e076e94171d5358e0282605bded
parent 442068 0534254e9a40b4bade2577c631fe4cfa0b5db41d
child 537692 9381a92065dd19daa72e6e6ee6d3a91c4f02b374
push id36578
push usermsreckovic@mozilla.com
push dateMon, 21 Nov 2016 17:49:13 +0000
reviewersaosmond
bugs1318007
milestone53.0a1
Bug 1318007: When the surface is already allocated, just check for non-positive dimensions. r?aosmond MozReview-Commit-ID: C0Fkq1SVO3s
gfx/2d/Factory.cpp
--- 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);