From ff05cd51eb2c6ac73e742ad0715105cae28b0d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 22 May 2025 09:38:35 +0000 Subject: [PATCH] Bug 1967479 - Clear vertices if GetOrBuildPathForMeasuring() fails. r=longsonr It's failing here: https://searchfox.org/mozilla-central/rev/02d33f4bf984f65bd394bfd2d19d66569ae2cfe1/dom/svg/SVGEllipseElement.cpp#157-159 Which makes sense I think, because off the zero radii. Keep the state consistent in that case. Differential Revision: https://phabricator.services.mozilla.com/D250624 --- dom/svg/SVGMotionSMILAnimationFunction.cpp | 29 ++++++++++--------- .../animations/mpath-zero-radius-crash.html | 18 ++++++++++++ 2 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 testing/web-platform/tests/svg/animations/mpath-zero-radius-crash.html diff --git a/dom/svg/SVGMotionSMILAnimationFunction.cpp b/dom/svg/SVGMotionSMILAnimationFunction.cpp index a36ecc4994f2..e860841ca670 100644 --- a/dom/svg/SVGMotionSMILAnimationFunction.cpp +++ b/dom/svg/SVGMotionSMILAnimationFunction.cpp @@ -208,17 +208,21 @@ void SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromMpathElem( mPathSourceType = ePathSourceType_Mpath; // Use the shape that's the target of our chosen child. - SVGGeometryElement* shapeElem = aMpathElem->GetReferencedPath(); - if (shapeElem && shapeElem->HasValidDimensions()) { - bool ok = shapeElem->GetDistancesFromOriginToEndsOfVisibleSegments( - &mPathVertices); - if (!ok) { - mPathVertices.Clear(); - return; - } - if (mPathVertices.Length()) { - mPath = shapeElem->GetOrBuildPathForMeasuring(); - } + SVGGeometryElement* shape = aMpathElem->GetReferencedPath(); + if (!shape || !shape->HasValidDimensions()) { + return; + } + if (!shape->GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices)) { + mPathVertices.Clear(); + return; + } + if (mPathVertices.IsEmpty()) { + return; + } + mPath = shape->GetOrBuildPathForMeasuring(); + if (!mPath) { + mPathVertices.Clear(); + return; } } @@ -237,7 +241,7 @@ void SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromPathAttr() { mPath = path.BuildPathForMeasuring(1.0f); bool ok = path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices); - if (!ok || !mPathVertices.Length()) { + if (!ok || mPathVertices.IsEmpty() || !mPath) { mPath = nullptr; mPathVertices.Clear(); } @@ -265,7 +269,6 @@ void SVGMotionSMILAnimationFunction::RebuildPathAndVertices( mValueNeedsReparsingEverySample = false; } else { // Get path & vertices from basic SMIL attrs: from/by/to/values - RebuildPathAndVerticesFromBasicAttrs(aTargetElement); mValueNeedsReparsingEverySample = true; } diff --git a/testing/web-platform/tests/svg/animations/mpath-zero-radius-crash.html b/testing/web-platform/tests/svg/animations/mpath-zero-radius-crash.html new file mode 100644 index 000000000000..a0528a27f5db --- /dev/null +++ b/testing/web-platform/tests/svg/animations/mpath-zero-radius-crash.html @@ -0,0 +1,18 @@ + + + + +