Bug 722444. Initialize mData for 0 sized surfaces. r=bgirard
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Mon, 30 Jan 2012 11:17:42 -0500
changeset 86981 e4ed1817e1a77d3b2ed4cc0d1a9bdb3026585876
parent 86980 bf005f6e4d5f39c42b3cb0c50e8e852f6d1cd7e0
child 86982 e42e07e4f6689480074274b7ca7e46f41e692c08
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard
bugs722444
milestone12.0a1
Bug 722444. Initialize mData for 0 sized surfaces. r=bgirard This avoids an invalid free() during destruction found with the online canvas test suite.
gfx/2d/DrawTargetCG.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -790,16 +790,17 @@ DrawTargetCG::DrawSurfaceWithShadow(Sour
 bool
 DrawTargetCG::Init(CGContextRef cgContext, const IntSize &aSize)
 {
   // XXX: we should come up with some consistent semantics for dealing
   // with zero area drawtargets
   if (aSize.width == 0 || aSize.height == 0) {
     mColorSpace = NULL;
     mCg = NULL;
+    mData = NULL;
     return false;
   }
 
   //XXX: handle SurfaceFormat
 
   //XXX: we'd be better off reusing the Colorspace across draw targets
   mColorSpace = CGColorSpaceCreateDeviceRGB();
 
@@ -824,16 +825,17 @@ DrawTargetCG::Init(CGContextRef cgContex
 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) {
     mColorSpace = NULL;
     mCg = NULL;
+    mData = NULL;
     return false;
   }
 
   //XXX: handle SurfaceFormat
 
   //XXX: we'd be better off reusing the Colorspace across draw targets
   mColorSpace = CGColorSpaceCreateDeviceRGB();