Bug 751515 - Fix Crash with convertToSpecifiedUnits. r=dholbert a=akeybl
authorRobert Longson <longsonr@gmail.com>
Fri, 04 May 2012 08:41:42 +0100
changeset 95652 ef89a868b38f90bc66b84f445ec2a6f63c1c03d7
parent 95651 dd43cd34d18c5fafebfa5bfacc79604549f1889f
child 95653 f4aacb7f246f7c54d3151dc3267ba9ab874d3c2f
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, akeybl
bugs751515
milestone14.0a2
Bug 751515 - Fix Crash with convertToSpecifiedUnits. r=dholbert a=akeybl
content/svg/content/src/crashtests/751515-1.svg
content/svg/content/src/crashtests/crashtests.list
content/svg/content/src/nsSVGAngle.cpp
new file mode 100644
--- /dev/null
+++ b/content/svg/content/src/crashtests/751515-1.svg
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+
+<svg xmlns="http://www.w3.org/2000/svg">
+<script>
+
+document.documentElement.createSVGAngle().convertToSpecifiedUnits(2);
+
+</script>
+</svg>
--- a/content/svg/content/src/crashtests/crashtests.list
+++ b/content/svg/content/src/crashtests/crashtests.list
@@ -54,8 +54,9 @@ load 579356-2.svg
 load 595608-1.svg
 load 601251-1.html
 load 601406-1.svg
 load 603145-1.svg
 load 613899-1.svg
 load 613899-2.svg
 load zero-size-image.svg
 load 723441-1.html
+load 751515-1.svg
--- a/content/svg/content/src/nsSVGAngle.cpp
+++ b/content/svg/content/src/nsSVGAngle.cpp
@@ -67,17 +67,17 @@ public:
   NS_IMETHOD GetUnitType(PRUint16* aResult)
     { *aResult = mVal.mBaseValUnit; return NS_OK; }
 
   NS_IMETHOD GetValue(float* aResult)
     { *aResult = mVal.GetBaseValue(); return NS_OK; }
   NS_IMETHOD SetValue(float aValue)
     {
       NS_ENSURE_FINITE(aValue, NS_ERROR_ILLEGAL_VALUE);
-      mVal.SetBaseValue(aValue, nsnull, true);
+      mVal.SetBaseValue(aValue, nsnull, false);
       return NS_OK;
     }
 
   NS_IMETHOD GetValueInSpecifiedUnits(float* aResult)
     { *aResult = mVal.mBaseVal; return NS_OK; }
   NS_IMETHOD SetValueInSpecifiedUnits(float aValue)
     {
       NS_ENSURE_FINITE(aValue, NS_ERROR_ILLEGAL_VALUE);
@@ -278,25 +278,30 @@ nsSVGAngle::ConvertToSpecifiedUnits(PRUi
                                     nsSVGElement *aSVGElement)
 {
   if (!IsValidUnitType(unitType))
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 
   if (mBaseValUnit == PRUint8(unitType))
     return NS_OK;
 
-  nsAttrValue emptyOrOldValue = aSVGElement->WillChangeAngle(mAttrEnum);
+  nsAttrValue emptyOrOldValue;
+  if (aSVGElement) {
+    emptyOrOldValue = aSVGElement->WillChangeAngle(mAttrEnum);
+  }
 
   float valueInUserUnits = mBaseVal * GetDegreesPerUnit(mBaseValUnit);
   mBaseValUnit = PRUint8(unitType);
   // Setting aDoSetAttr to false here will ensure we don't call
   // Will/DidChangeAngle a second time (and dispatch duplicate notifications).
   SetBaseValue(valueInUserUnits, aSVGElement, false);
 
-  aSVGElement->DidChangeAngle(mAttrEnum, emptyOrOldValue);
+  if (aSVGElement) {
+    aSVGElement->DidChangeAngle(mAttrEnum, emptyOrOldValue);
+  }
 
   return NS_OK;
 }
 
 nsresult
 nsSVGAngle::NewValueSpecifiedUnits(PRUint16 unitType,
                                    float valueInSpecifiedUnits,
                                    nsSVGElement *aSVGElement)