REGRESSION (r149928): CanvasStyle::operator= leaks everything
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 16:00:36 +0000 (16:00 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 16:00:36 +0000 (16:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121591

Reviewed by Andreas Kling.

* html/canvas/CanvasStyle.cpp: (WebCore::CanvasStyle::operator=): Don't leak.

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

Source/WebCore/ChangeLog
Source/WebCore/html/canvas/CanvasStyle.cpp

index 5cd6ca2..f692ba2 100644 (file)
@@ -1,3 +1,12 @@
+2013-09-19  Alexey Proskuryakov  <ap@apple.com>
+
+        REGRESSION (r149928): CanvasStyle::operator= leaks everything
+        https://bugs.webkit.org/show_bug.cgi?id=121591
+
+        Reviewed by Andreas Kling.
+
+        * html/canvas/CanvasStyle.cpp: (WebCore::CanvasStyle::operator=): Don't leak.
+
 2013-09-19  Andrei Parvu  <parvu@adobe.com>
 
         [CSS Masking/Background] Position property should be ignored when using repeat: space
 2013-09-19  Andrei Parvu  <parvu@adobe.com>
 
         [CSS Masking/Background] Position property should be ignored when using repeat: space
index a4ab348..5b5e005 100644 (file)
@@ -238,13 +238,8 @@ CanvasStyle::CanvasStyle(const CanvasStyle& other)
 CanvasStyle& CanvasStyle::operator=(const CanvasStyle& other)
 {
     if (this != &other) {
 CanvasStyle& CanvasStyle::operator=(const CanvasStyle& other)
 {
     if (this != &other) {
-        memcpy(this, &other, sizeof(CanvasStyle));
-        if (m_type == Gradient)
-            m_gradient->ref();
-        else if (m_type == ImagePattern)
-            m_pattern->ref();
-        else if (m_type == CMYKA)
-            m_cmyka = new CMYKAValues(other.m_cmyka->rgba, other.m_cmyka->c, other.m_cmyka->m, other.m_cmyka->y, other.m_cmyka->k, other.m_cmyka->a);
+        this->~CanvasStyle();
+        new (this) CanvasStyle(other);
     }
     return *this;
 }
     }
     return *this;
 }