Bug 719429. Fix canvas data leak in DrawTargetCG. r=ajuma
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Thu, 19 Jan 2012 10:33:35 -0500
changeset 86139 e55e8be05041f82ca839312c55f409e1f5148ef4
parent 86138 16a7c717fad02eeb4a2f4c48e847a8d63e78349f
child 86140 23b59d488767362c94803b2e1818d91086a19528
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)
reviewersajuma
bugs719429
milestone12.0a1
Bug 719429. Fix canvas data leak in DrawTargetCG. r=ajuma I forgot to fix this before landing and refound it using http://s3.zazub.com/games/circle_game/index.html
gfx/2d/DrawTargetCG.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -111,16 +111,17 @@ DrawTargetCG::DrawTargetCG()
 
 DrawTargetCG::~DrawTargetCG()
 {
   // We need to conditionally release these because Init can fail without initializing these.
   if (mColorSpace)
     CGColorSpaceRelease(mColorSpace);
   if (mCg)
     CGContextRelease(mCg);
+  free(mData);
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetCG::Snapshot()
 {
   RefPtr<SourceSurfaceCG> newSurf = new SourceSurfaceCG(CGBitmapContextCreateImage(mCg));
   return newSurf;
 }
@@ -840,17 +841,16 @@ DrawTargetCG::Init(const IntSize &aSize,
 
   CGBitmapInfo bitinfo;
 
   bitinfo = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst;
 
   // XXX: currently we allocate ourselves so that we can easily return a gfxImageSurface
   // we might not need to later if once we don't need to support gfxImageSurface
   //XXX: currently Init implicitly clears, that can often be a waste of time
-  // XXX: leaked
   mData = calloc(mSize.height * stride, 1);
   // XXX: what should we do if this fails?
   mCg = CGBitmapContextCreate (mData,
                                mSize.width,
                                mSize.height,
                                bitsPerComponent,
                                stride,
                                mColorSpace,