Browse files

DO NOT MERGE Fix memory leak

 Cherry pick

 Bug: 6952980
 GraphicsContext::createOffscreenContext creates an instance of both
 PlatformGraphicsSkia and GraphicsContext for ImageBuffer. However,
 ImageBuffer will only call delete on the GraphicsContext. In normal
 GC usage, the PlatformGraphicsContext's lifecycle is longer than the
 GCs, and is cleaned up by itself. This will result in leaking the
 PlatformGraphicsSkia context, though. We need to make sure to call
 delete on the PlatformGraphicsSkia context if we were initialized
 with the deleteUs() flag, which is used to indicate just this scenario.

Change-Id: If908dcb44e99568b92ee63d6337ce9f84adc9adf
  • Loading branch information...
1 parent 0e8bb60 commit 28c43cfac56492d4d307386c44ab9a1121f7d3bf @jreck jreck committed Aug 9, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
@@ -58,6 +58,12 @@ class GraphicsContextPlatformPrivate {
GraphicsContextPlatformPrivate(PlatformGraphicsContext* platformContext)
: m_context(platformContext) { }
+ ~GraphicsContextPlatformPrivate()
+ {
+ if (m_context->deleteUs())
+ delete m_context;
+ }
PlatformGraphicsContext* context() { return m_context; }

0 comments on commit 28c43cf

Please sign in to comment.