Title: [149370] trunk/Source/WebCore
Revision
149370
Author
[email protected]
Date
2013-04-30 08:00:56 -0700 (Tue, 30 Apr 2013)

Log Message

[BlackBerry] ImageBuffer::copyImage leaking memory
https://bugs.webkit.org/show_bug.cgi?id=115359

Patch by Mike Lattanzio <[email protected]> on 2013-04-30
Reviewed by George Staikos.

Use a WebCore::Vector to ensure the temporary data is destroyed.
The TiledImage does not take ownership of the data.

* platform/graphics/blackberry/ImageBufferBlackBerry.cpp:
(WebCore::ImageBuffer::copyImage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (149369 => 149370)


--- trunk/Source/WebCore/ChangeLog	2013-04-30 14:39:56 UTC (rev 149369)
+++ trunk/Source/WebCore/ChangeLog	2013-04-30 15:00:56 UTC (rev 149370)
@@ -1,3 +1,16 @@
+2013-04-30  Mike Lattanzio  <[email protected]>
+
+        [BlackBerry] ImageBuffer::copyImage leaking memory
+        https://bugs.webkit.org/show_bug.cgi?id=115359
+
+        Reviewed by George Staikos.
+
+        Use a WebCore::Vector to ensure the temporary data is destroyed.
+        The TiledImage does not take ownership of the data.
+
+        * platform/graphics/blackberry/ImageBufferBlackBerry.cpp:
+        (WebCore::ImageBuffer::copyImage):
+
 2013-04-30  Noam Rosenthal  <[email protected]>
 
         [Texmap] Avoid using overlap/non-overlap region in cases where the overhead is bigger than the gain

Modified: trunk/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp (149369 => 149370)


--- trunk/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp	2013-04-30 14:39:56 UTC (rev 149369)
+++ trunk/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp	2013-04-30 15:00:56 UTC (rev 149370)
@@ -32,6 +32,7 @@
 #include <BlackBerryPlatformGraphicsContext.h>
 #include <BlackBerryPlatformSettings.h>
 #include <BlackBerryPlatformWindow.h>
+#include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
 using namespace std;
@@ -210,10 +211,10 @@
 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy, ScaleBehavior) const
 {
     // FIXME respect copyBehaviour enum.
-    unsigned* imageData = new unsigned[m_size.width() * m_size.height()];
-    m_data.getImageData(m_context.get(), IntRect(IntPoint(0, 0), m_size), IntRect(IntPoint(0, 0), m_size), (unsigned char*)imageData, false /* unmultiply */);
-    BlackBerry::Platform::Graphics::TiledImage* nativeImage = new BlackBerry::Platform::Graphics::TiledImage(m_size, imageData, false /* dataIsBGRA */);
-    return BitmapImage::create(nativeImage);
+    Vector<unsigned> pixels;
+    pixels.reserveCapacity(m_size.area());
+    m_data.getImageData(m_context.get(), IntRect(IntPoint(0, 0), m_size), IntRect(IntPoint(0, 0), m_size), reinterpret_cast<unsigned char*>(pixels.data()), false /* unmultiply */);
+    return BitmapImage::create(new BlackBerry::Platform::Graphics::TiledImage(m_size, pixels.data(), false /* dataIsBGRA */));
 }
 
 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to