Skip to content

fix: Avoid RangeError when toDashedPath receives an empty dashArray#2105

Open
ultramcu wants to merge 1 commit into
imaNNeo:mainfrom
ultramcu:fix/dashed-path-empty-array
Open

fix: Avoid RangeError when toDashedPath receives an empty dashArray#2105
ultramcu wants to merge 1 commit into
imaNNeo:mainfrom
ultramcu:fix/dashed-path-empty-array

Conversation

@ultramcu

Copy link
Copy Markdown

Description

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.

A regression test is added next to the existing toDashedPath test:
expect(path.toDashedPath([]), path) on a non-empty source path; before the
fix this throws RangeError, after the fix it passes by returning this
(verified fail-before / pass-after locally; full test suite green: +664/664).

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • [-] I have updated/added relevant documentation and added dartdoc comments with ///. (Internal-loop fix; no public API surface change.)
  • [-] I have updated/added relevant examples in example. (Bug fix in existing behaviour; example app unchanged.)

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant