Bug 788862: Initialize 'segType' in SVGPathData::ConstructPath. r=jwatt
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 06 Sep 2012 11:33:01 -0700
changeset 111360 6337d6dd972777dfc3068c3c2ff82ab6f6e02caa
parent 111359 972343e2fd90ed2b03af529ff9d589e8d19a3d6f
child 111361 ce658303181e168f7ab45ff361ecb4b759d90dd5
push id239
push userakeybl@mozilla.com
push dateThu, 03 Jan 2013 21:54:43 +0000
treeherdermozilla-release@3a7b66445659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs788862
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 788862: Initialize 'segType' in SVGPathData::ConstructPath. r=jwatt
content/svg/content/src/SVGPathData.cpp
--- a/content/svg/content/src/SVGPathData.cpp
+++ b/content/svg/content/src/SVGPathData.cpp
@@ -245,25 +245,26 @@ ApproximateZeroLengthSubpathSquareCaps(c
          segType == nsIDOMSVGPathSeg::PATHSEG_CLOSEPATH)) {                   \
       ApproximateZeroLengthSubpathSquareCaps(segStart, aCtx);                 \
     }                                                                         \
   } while(0)
 
 void
 SVGPathData::ConstructPath(gfxContext *aCtx) const
 {
-  if (!mData.Length() || !IsMoveto(SVGPathSegUtils::DecodeType(mData[0]))) {
+  if (mData.IsEmpty() || !IsMoveto(SVGPathSegUtils::DecodeType(mData[0]))) {
     return; // paths without an initial moveto are invalid
   }
 
   bool capsAreSquare = aCtx->CurrentLineCap() == gfxContext::LINE_CAP_SQUARE;
   bool subpathHasLength = false;  // visual length
   bool subpathContainsNonArc = false;
 
-  uint32_t segType, prevSegType = nsIDOMSVGPathSeg::PATHSEG_UNKNOWN;
+  uint32_t segType     = nsIDOMSVGPathSeg::PATHSEG_UNKNOWN;
+  uint32_t prevSegType = nsIDOMSVGPathSeg::PATHSEG_UNKNOWN;
   gfxPoint pathStart(0.0, 0.0); // start point of [sub]path
   gfxPoint segStart(0.0, 0.0);
   gfxPoint segEnd;
   gfxPoint cp1, cp2;            // previous bezier's control points
   gfxPoint tcp1, tcp2;          // temporaries
 
   // Regarding cp1 and cp2: If the previous segment was a cubic bezier curve,
   // then cp2 is its second control point. If the previous segment was a
@@ -480,16 +481,18 @@ SVGPathData::ConstructPath(gfxContext *a
       return; // according to spec we'd use everything up to the bad seg anyway
     }
     i += argCount;
     prevSegType = segType;
     segStart = segEnd;
   }
 
   NS_ABORT_IF_FALSE(i == mData.Length(), "Very, very bad - mData corrupt");
+  NS_ABORT_IF_FALSE(prevSegType == segType,
+                    "prevSegType should be left at the final segType");
 
   MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS;
 }
 
 already_AddRefed<gfxFlattenedPath>
 SVGPathData::ToFlattenedPath(const gfxMatrix& aMatrix) const
 {
   nsRefPtr<gfxContext> tmpCtx =