Bug 1081350 - Fix leak in clip-path computed style code. r=bz
authorDirk Schulze <dschulze@adobe.com>
Sun, 12 Oct 2014 13:14:00 +0200
changeset 210330 7a05af7d4902a2d83fdf2be43928290b5a567970
parent 210329 f3f97d35b18016460c99c94b460c80c28341545c
child 210331 073e83cef2381484ade504b58df6f845b796ed84
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbz
bugs1081350
milestone36.0a1
Bug 1081350 - Fix leak in clip-path computed style code. r=bz
layout/style/nsComputedDOMStyle.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -5178,18 +5178,16 @@ nsComputedDOMStyle::DoGetStopColor()
 CSSValue*
 nsComputedDOMStyle::CreatePrimitiveValueForClipPath(
   const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox)
 {
   nsDOMCSSValueList* valueList = GetROCSSValueList(false);
 
   if (aStyleBasicShape &&
       aStyleBasicShape->GetShapeType() == nsStyleBasicShape::Type::ePolygon) {
-    nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
-
     // Shape function name and opening parenthesis.
     nsAutoString shapeFunctionString;
     AppendASCIItoUTF16(nsCSSKeywords::GetStringValue(eCSSKeyword_polygon),
                        shapeFunctionString);
     shapeFunctionString.Append('(');
     bool hasEvenOdd = aStyleBasicShape->GetFillRule() ==
                           NS_STYLE_FILL_RULE_EVENODD;
     if (hasEvenOdd) {
@@ -5204,31 +5202,31 @@ nsComputedDOMStyle::CreatePrimitiveValue
                         aStyleBasicShape->Coordinates()[i]);
       shapeFunctionString.Append(coordString);
       shapeFunctionString.Append(' ');
       SetCssTextToCoord(coordString,
                         aStyleBasicShape->Coordinates()[i + 1]);
       shapeFunctionString.Append(coordString);
     }
     shapeFunctionString.Append(')');
+    nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
     val->SetString(shapeFunctionString);
     valueList->AppendCSSValue(val);
   }
 
-  nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
-
   if (aSizingBox == NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) {
     return valueList;
   }
 
   nsAutoString boxString;
   AppendASCIItoUTF16(
     nsCSSProps::ValueToKeyword(aSizingBox,
                                nsCSSProps::kClipShapeSizingKTable),
                                boxString);
+  nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
   val->SetString(boxString);
   valueList->AppendCSSValue(val);
 
   return valueList;
 }
 
 CSSValue*
 nsComputedDOMStyle::DoGetClipPath()