LayoutTests:
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Aug 2007 08:42:38 +0000 (08:42 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Aug 2007 08:42:38 +0000 (08:42 +0000)
        Reviewed by Maciej.

        Simple test to ensure we don't crash when creating a pattern

        * fast/canvas/create-pattern-does-not-crash-expected.txt: Added.
        * fast/canvas/create-pattern-does-not-crash.html: Added.

WebCore:

        Reviewed by Maciej.

        http://bugs.webkit.org/show_bug.cgi?id=14189
        <rdar://problem/5319511> REPRODUCIBLE CRASH: Canvas createPattern(canvas, ...) crashes on Windows (14189)

        Ensure that we actually retain the CG pattern correctly.

        Credit to Philip Taylor <excors@gmail.com> for finding the cause of this.

        * html/CanvasPattern.cpp:
        (WebCore::CanvasPattern::~CanvasPattern):
        (WebCore::CanvasPattern::createPattern):
        * html/CanvasPattern.h:
        (WebCore::CanvasPattern::platformImage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25124 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/canvas/create-pattern-does-not-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/create-pattern-does-not-crash.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/CanvasPattern.cpp
WebCore/html/CanvasPattern.h

index 958ef1da244caf1f177f82e197c6e9a2a9f97763..6e4bb0bae2f34e67737a20468bf7e186817ba6a5 100644 (file)
@@ -1,3 +1,12 @@
+2007-08-17  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Maciej.
+
+        Simple test to ensure we don't crash when creating a pattern
+
+        * fast/canvas/create-pattern-does-not-crash-expected.txt: Added.
+        * fast/canvas/create-pattern-does-not-crash.html: Added.
+
 2007-08-16  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by Harrison.
diff --git a/LayoutTests/fast/canvas/create-pattern-does-not-crash-expected.txt b/LayoutTests/fast/canvas/create-pattern-does-not-crash-expected.txt
new file mode 100644 (file)
index 0000000..4501ed5
--- /dev/null
@@ -0,0 +1,2 @@
+
+This test case ensures we don't crash when using canvas.createPattern
diff --git a/LayoutTests/fast/canvas/create-pattern-does-not-crash.html b/LayoutTests/fast/canvas/create-pattern-does-not-crash.html
new file mode 100644 (file)
index 0000000..e2db81d
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<canvas id="c"></canvas><br/>
+This test case ensures we don't crash when using canvas.createPattern
+<script>
+window.onload = function ()
+{
+    if (window.layoutTestController)
+        window.layoutTestController.dumpAsText();
+    var canvas = document.getElementById('c');
+    var ctx = canvas.getContext('2d');
+    var p = ctx.createPattern(canvas, 'no-repeat');
+}
+</script>
index acc61cca7ba28bad5cbfabdaed346c00d0955916..26345c1a091d254144226c4ef37a1687b5b47797 100644 (file)
@@ -1,3 +1,20 @@
+2007-08-17  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Maciej.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14189
+        <rdar://problem/5319511> REPRODUCIBLE CRASH: Canvas createPattern(canvas, ...) crashes on Windows (14189)
+
+        Ensure that we actually retain the CG pattern correctly.
+
+        Credit to Philip Taylor <excors@gmail.com> for finding the cause of this.
+
+        * html/CanvasPattern.cpp:
+        (WebCore::CanvasPattern::~CanvasPattern):
+        (WebCore::CanvasPattern::createPattern):
+        * html/CanvasPattern.h:
+        (WebCore::CanvasPattern::platformImage):
+
 2007-08-16  Geoffrey Garen  <ggaren@apple.com>
 
         Build fix. (Maybe?)
index d645fb1a91113b2573f13cc9920f946a3b2c9bb6..ae0dfc7d2b4fa135fd7b84158d2d5411ee4bab2f 100644 (file)
@@ -91,9 +91,6 @@ CanvasPattern::CanvasPattern(CachedImage* cachedImage, bool repeatX, bool repeat
 
 CanvasPattern::~CanvasPattern()
 {
-#if PLATFORM(CG)
-    CGImageRelease(m_platformImage);
-#endif
     if (m_cachedImage)
         m_cachedImage->deref(this);
 }
@@ -142,8 +139,8 @@ CGPatternRef CanvasPattern::createPattern(const CGAffineTransform& transform)
     rect.origin.x = 0;
     rect.origin.y = 0;
     if (m_platformImage) {
-        rect.size.width = CGImageGetWidth(m_platformImage);
-        rect.size.height = CGImageGetHeight(m_platformImage);
+        rect.size.width = CGImageGetWidth(m_platformImage.get());
+        rect.size.height = CGImageGetHeight(m_platformImage.get());
     } else {
         if (!m_cachedImage)
             return 0;
index ef1ed41773cb0fa0a297fda8155ea06646ad7288..86f8f5287af782b5039cefc57f5473a4e9b97740 100644 (file)
@@ -30,6 +30,7 @@
 #include "Shared.h"
 
 #if PLATFORM(CG)
+#include <wtf/RetainPtr.h>
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
@@ -51,7 +52,7 @@ namespace WebCore {
         ~CanvasPattern();
 
 #if PLATFORM(CG)
-        CGImageRef platformImage() const { return m_platformImage; }
+        CGImageRef platformImage() const { return m_platformImage.get(); }
 #endif
         CachedImage* cachedImage() const { return m_cachedImage; }
 
@@ -61,7 +62,7 @@ namespace WebCore {
 
     private:
 #if PLATFORM(CG)
-        const CGImageRef m_platformImage;
+        const RetainPtr<CGImageRef> m_platformImage;
 #endif
         CachedImage* const m_cachedImage;
         const bool m_repeatX;