Bug 1279628, part 1 - Add the CoreGraphics check from gfxASurface::CheckSurfaceSize to Factory::CheckSurfaceSize. r=mstange
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -260,16 +260,25 @@ Factory::CheckSurfaceSize(const IntSize
}
// reject images with sides bigger than limit
if (extentLimit && (sz.width > extentLimit || sz.height > extentLimit)) {
gfxDebug() << "Surface size too large (exceeds extent limit)!";
return false;
}
+#if defined(XP_MACOSX)
+ // CoreGraphics is limited to images < 32K in *height*,
+ // so clamp all surfaces on the Mac to that height
+ if (sz.height > SHRT_MAX) {
+ gfxDebug() << "Surface size too large (exceeds CoreGraphics limit)!";
+ return false;
+ }
+#endif
+
// make sure the surface area doesn't overflow a int32_t
CheckedInt<int32_t> tmp = sz.width;
tmp *= sz.height;
if (!tmp.isValid()) {
gfxDebug() << "Surface size too large (would overflow)!";
return false;
}