Bug 617971 nsStyleAnimation::ExtractComputedValue leaks pair when StyleCoordToCSSValue fails.
authortimeless@mozdev.org
Fri, 10 Dec 2010 10:31:37 -0800
changeset 59083 5677a819829a93139c49da9fa43a0b6a23b10a4e
parent 59082 8bb8491b45af80469c0e765509cf83e47bdae2a6
child 59084 89e633e31dad283de4e541b988eafae4a815ba20
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs617971
milestone2.0b8pre
Bug 617971 nsStyleAnimation::ExtractComputedValue leaks pair when StyleCoordToCSSValue fails. r=bz a=bz
layout/style/nsStyleAnimation.cpp
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -2237,39 +2237,39 @@ nsStyleAnimation::ExtractComputedValue(n
                                        eUnit_Integer);
           }
           break;
         }
 
         case eCSSProperty_border_spacing: {
           const nsStyleTableBorder *styleTableBorder =
             static_cast<const nsStyleTableBorder*>(styleStruct);
-          nsCSSValuePair *pair = new nsCSSValuePair;
+          nsAutoPtr<nsCSSValuePair> pair(new nsCSSValuePair);
           if (!pair) {
             return PR_FALSE;
           }
           nscoordToCSSValue(styleTableBorder->mBorderSpacingX, pair->mXValue);
           nscoordToCSSValue(styleTableBorder->mBorderSpacingY, pair->mYValue);
-          aComputedValue.SetAndAdoptCSSValuePairValue(pair,
+          aComputedValue.SetAndAdoptCSSValuePairValue(pair.forget(),
                                                       eUnit_CSSValuePair);
           break;
         }
 
         case eCSSProperty__moz_transform_origin: {
           const nsStyleDisplay *styleDisplay =
             static_cast<const nsStyleDisplay*>(styleStruct);
-          nsCSSValuePair *pair = new nsCSSValuePair;
+          nsAutoPtr<nsCSSValuePair> pair(new nsCSSValuePair);
           if (!pair ||
               !StyleCoordToCSSValue(styleDisplay->mTransformOrigin[0],
                                     pair->mXValue) ||
               !StyleCoordToCSSValue(styleDisplay->mTransformOrigin[1],
                                     pair->mYValue)) {
             return PR_FALSE;
           }
-          aComputedValue.SetAndAdoptCSSValuePairValue(pair,
+          aComputedValue.SetAndAdoptCSSValuePairValue(pair.forget(),
                                                       eUnit_CSSValuePair);
           break;
         }
 
         case eCSSProperty_stroke_dasharray: {
           const nsStyleSVG *svg = static_cast<const nsStyleSVG*>(styleStruct);
           NS_ABORT_IF_FALSE((svg->mStrokeDasharray != nsnull) ==
                             (svg->mStrokeDasharrayLength != 0),
@@ -2566,23 +2566,24 @@ nsStyleAnimation::ExtractComputedValue(n
                        == NS_CORNER_BOTTOM_LEFT);
       const nsStyleCorners *corners = static_cast<const nsStyleCorners*>(
         StyleDataAtOffset(styleStruct, ssOffset));
       PRUint8 fullCorner = animType - eStyleAnimType_Corner_TopLeft;
       const nsStyleCoord &horiz =
         corners->Get(NS_FULL_TO_HALF_CORNER(fullCorner, PR_FALSE));
       const nsStyleCoord &vert =
         corners->Get(NS_FULL_TO_HALF_CORNER(fullCorner, PR_TRUE));
-      nsCSSValuePair *pair = new nsCSSValuePair;
+      nsAutoPtr<nsCSSValuePair> pair(new nsCSSValuePair);
       if (!pair ||
           !StyleCoordToCSSValue(horiz, pair->mXValue) ||
           !StyleCoordToCSSValue(vert, pair->mYValue)) {
         return PR_FALSE;
       }
-      aComputedValue.SetAndAdoptCSSValuePairValue(pair, eUnit_CSSValuePair);
+      aComputedValue.SetAndAdoptCSSValuePairValue(pair.forget(),
+                                                  eUnit_CSSValuePair);
       return PR_TRUE;
     }
     case eStyleAnimType_nscoord:
       aComputedValue.SetCoordValue(*static_cast<const nscoord*>(
         StyleDataAtOffset(styleStruct, ssOffset)));
       return PR_TRUE;
     case eStyleAnimType_EnumU8:
       aComputedValue.SetIntValue(*static_cast<const PRUint8*>(