From ddb9860fb5d82fbf1a96746d26d1b7b39a8ef8a2 Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 8 Aug 2012 17:27:13 -0700 Subject: Fix memory leak 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: I73aa623182a039bd75d378d198cc3bd2d4d185ef --- .../platform/graphics/android/context/GraphicsContextAndroid.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/WebCore') diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp index 970b04b..23b22e6 100644 --- a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp @@ -57,6 +57,12 @@ class GraphicsContextPlatformPrivate { public: GraphicsContextPlatformPrivate(PlatformGraphicsContext* platformContext) : m_context(platformContext) { } + ~GraphicsContextPlatformPrivate() + { + if (m_context->deleteUs()) + delete m_context; + } + PlatformGraphicsContext* context() { return m_context; } -- cgit v1.1