Bug 731117. Bound the size of CG surfaces to match cairo. r=bas, a=akeybl
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Wed, 29 Feb 2012 21:30:11 -0500
changeset 87312 054df423ec81da987fd878ec1b0010d22b53aed0
parent 87311 086fa692e38b6fcb7a7b1bbc44a36ceb712e137d
child 87313 cbfa968b61f551d85265fd3d37884ca095eb5ebf
push id942
push userjmuizelaar@mozilla.com
push dateWed, 07 Mar 2012 03:27:53 +0000
treeherdermozilla-aurora@054df423ec81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, akeybl
bugs731117
milestone12.0a2
Bug 731117. Bound the size of CG surfaces to match cairo. r=bas, a=akeybl This fixes crashes that can happen when we try to create an image surface from a quartz surface larger than the maximum size supported by image surfaces.
gfx/2d/DrawTargetCG.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -867,17 +867,20 @@ DrawTargetCG::Init(CGContextRef cgContex
   return true;
 }
 
 bool
 DrawTargetCG::Init(const IntSize &aSize, SurfaceFormat &)
 {
   // XXX: we should come up with some consistent semantics for dealing
   // with zero area drawtargets
-  if (aSize.width == 0 || aSize.height == 0) {
+  if (aSize.width == 0 || aSize.height == 0 ||
+      // 32767 is the maximum size supported by cairo
+      // we clamp to that to make it easier to interoperate
+      aSize.width > 32767 || aSize.height > 32767) {
     mColorSpace = NULL;
     mCg = NULL;
     mData = NULL;
     return false;
   }
 
   //XXX: handle SurfaceFormat