summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-08-08 17:27:13 -0700
committerJohn Reck <jreck@google.com>2012-08-09 10:24:16 -0700
commit28c43cfac56492d4d307386c44ab9a1121f7d3bf (patch)
treef94fbd32d41b138fb7a3f237ce04e4bef8721ef9
parent0e8bb60087a019d104b6eb4aa8abd11bd91b16c4 (diff)
downloadwebkit-28c43cfac56492d4d307386c44ab9a1121f7d3bf.tar.gz
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
-rw-r--r--Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
index f2d1400fc..3b93d513a 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
@@ -58,6 +58,12 @@ class GraphicsContextPlatformPrivate {
public:
GraphicsContextPlatformPrivate(PlatformGraphicsContext* platformContext)
: m_context(platformContext) { }
+ ~GraphicsContextPlatformPrivate()
+ {
+ if (m_context->deleteUs())
+ delete m_context;
+ }
+
PlatformGraphicsContext* context() { return m_context; }