fix: Avoid RangeError when toDashedPath receives an empty dashArray#2105
Open
ultramcu wants to merge 1 commit into
Open
fix: Avoid RangeError when toDashedPath receives an empty dashArray#2105ultramcu wants to merge 1 commit into
ultramcu wants to merge 1 commit into
Conversation
`Path.toDashedPath([])` reached `CircularIntervalList<double>([]).next` inside `dashPath()`, which indexed an empty list and threw `RangeError` for any non-empty source path. The same crash was reachable indirectly via animation: `lerpIntList` / `lerpList` can produce an empty list at mid-tween when interpolating between a non-empty `dashArray` and `null`, turning a configuration change into a paint-frame crash. An empty dash spec has no dashes to repeat, so the source path is now returned unchanged — mirroring the existing `null` branch's semantics and matching what every current caller (line/bar painters, CanvasWrapper) expects when no dash pattern is given.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Path.toDashedPath([])reachedCircularIntervalList<double>([]).nextinsidedashPath(), which indexed an empty list and threwRangeErrorfor anynon-empty source path. The same crash was reachable indirectly via animation:
lerpIntList/lerpListcan produce an empty list at mid-tween wheninterpolating between a non-empty
dashArrayandnull, turning aconfiguration change into a paint-frame crash.
An empty dash spec has no dashes to repeat, so the source path is now returned
unchanged — mirroring the existing
nullbranch's semantics and matching whatevery current caller (line/bar painters,
CanvasWrapper) expects when no dashpattern is given.
A regression test is added next to the existing
toDashedPathtest:expect(path.toDashedPath([]), path)on a non-empty source path; before thefix this throws
RangeError, after the fix it passes by returningthis(verified fail-before / pass-after locally; full test suite green: +664/664).
Checklist
///. (Internal-loop fix; no public API surface change.)example. (Bug fix in existing behaviour; example app unchanged.)Breaking Change?