Title: [127838] trunk/Source/WebCore
Revision
127838
Author
macpher...@chromium.org
Date
2012-09-07 00:48:18 -0700 (Fri, 07 Sep 2012)

Log Message

Make CSSPrimitiveValue::cleanup() handle all UnitTypes, fixing memory leak in the process.
https://bugs.webkit.org/show_bug.cgi?id=95938

Reviewed by Andreas Kling.

Several unit types have been added without updating the cleanup function, including CSS_VARIABLE_NAME.
I've added all the existing unit types back in and cast m_primitiveUnitType (a bitfield in CSSValue)
to the enum type to ensure the compiler catches any future errors.

No test added, but switch made to use enum type so we can't accidentally fail to update this function again.

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::cleanup):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127837 => 127838)


--- trunk/Source/WebCore/ChangeLog	2012-09-07 07:45:49 UTC (rev 127837)
+++ trunk/Source/WebCore/ChangeLog	2012-09-07 07:48:18 UTC (rev 127838)
@@ -1,3 +1,19 @@
+2012-09-07  Luke Macpherson   <macpher...@chromium.org>
+
+        Make CSSPrimitiveValue::cleanup() handle all UnitTypes, fixing memory leak in the process.
+        https://bugs.webkit.org/show_bug.cgi?id=95938
+
+        Reviewed by Andreas Kling.
+
+        Several unit types have been added without updating the cleanup function, including CSS_VARIABLE_NAME.
+        I've added all the existing unit types back in and cast m_primitiveUnitType (a bitfield in CSSValue)
+        to the enum type to ensure the compiler catches any future errors.
+
+        No test added, but switch made to use enum type so we can't accidentally fail to update this function again.
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::cleanup):
+
 2012-09-07  Tim Horton  <timothy_hor...@apple.com>
 
         Add optional debug logging when we fall into/out of threaded scrolling

Modified: trunk/Source/WebCore/css/CSSParserValues.cpp (127837 => 127838)


--- trunk/Source/WebCore/css/CSSParserValues.cpp	2012-09-07 07:45:49 UTC (rev 127837)
+++ trunk/Source/WebCore/css/CSSParserValues.cpp	2012-09-07 07:48:18 UTC (rev 127838)
@@ -124,7 +124,9 @@
     case CSSPrimitiveValue::CSS_DPI:
     case CSSPrimitiveValue::CSS_DPCM:
     case CSSPrimitiveValue::CSS_PAIR:
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
     case CSSPrimitiveValue::CSS_DASHBOARD_REGION:
+#endif
     case CSSPrimitiveValue::CSS_UNICODE_RANGE:
     case CSSPrimitiveValue::CSS_PARSER_OPERATOR:
     case CSSPrimitiveValue::CSS_PARSER_INTEGER:

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (127837 => 127838)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2012-09-07 07:45:49 UTC (rev 127837)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2012-09-07 07:48:18 UTC (rev 127838)
@@ -91,7 +91,9 @@
     case CSSPrimitiveValue:: CSS_ATTR:
     case CSSPrimitiveValue:: CSS_COUNTER:
     case CSSPrimitiveValue:: CSS_COUNTER_NAME:
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
     case CSSPrimitiveValue:: CSS_DASHBOARD_REGION:
+#endif
 #if !ENABLE(CSS_IMAGE_RESOLUTION)
     case CSSPrimitiveValue:: CSS_DPPX:
     case CSSPrimitiveValue:: CSS_DPI:
@@ -365,11 +367,14 @@
 
 void CSSPrimitiveValue::cleanup()
 {
-    switch (m_primitiveUnitType) {
+    switch (static_cast<UnitTypes>(m_primitiveUnitType)) {
     case CSS_STRING:
     case CSS_URI:
     case CSS_ATTR:
     case CSS_COUNTER_NAME:
+#if ENABLE(CSS_VARIABLES)
+    case CSS_VARIABLE_NAME:
+#endif
     case CSS_PARSER_HEXCOLOR:
         if (m_value.string)
             m_value.string->deref();
@@ -386,7 +391,7 @@
     case CSS_PAIR:
         m_value.pair->deref();
         break;
-#if ENABLE(DASHBOARD_SUPPORT)
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
     case CSS_DASHBOARD_REGION:
         if (m_value.region)
             m_value.region->deref();
@@ -395,6 +400,10 @@
     case CSS_CALC:
         m_value.calc->deref();
         break;
+    case CSS_CALC_PERCENTAGE_WITH_NUMBER:
+    case CSS_CALC_PERCENTAGE_WITH_LENGTH:
+        ASSERT_NOT_REACHED();
+        break;
     case CSS_SHAPE:
         m_value.shape->deref();
         break;
@@ -421,10 +430,14 @@
     case CSS_VW:
     case CSS_VH:
     case CSS_VMIN:
+    case CSS_DPPX:
+    case CSS_DPI:
+    case CSS_DPCM:
     case CSS_IDENT:
     case CSS_RGBCOLOR:
     case CSS_DIMENSION:
     case CSS_UNKNOWN:
+    case CSS_UNICODE_RANGE:
     case CSS_PARSER_OPERATOR:
     case CSS_PARSER_IDENTIFIER:
         break;

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (127837 => 127838)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2012-09-07 07:45:49 UTC (rev 127837)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2012-09-07 07:48:18 UTC (rev 127838)
@@ -99,7 +99,9 @@
         CSS_DPI = 30,
         CSS_DPCM = 31,
         CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
         CSS_DASHBOARD_REGION = 101, // FIXME: Dashboard region should not be a primitive value.
+#endif
         CSS_UNICODE_RANGE = 102,
 
         // These next types are just used internally to allow us to translate back and forth from CSSPrimitiveValues to CSSParserValues.
@@ -282,7 +284,9 @@
     Pair* getPairValue(ExceptionCode&) const;
     Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_value.pair; }
 
+#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
     DashboardRegion* getDashboardRegionValue() const { return m_primitiveUnitType != CSS_DASHBOARD_REGION ? 0 : m_value.region; }
+#endif
 
     CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? 0 : m_value.shape; }
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to