Comment 6 for bug 1646595

Revision history for this message
Mitch Bradley (wmb-a) wrote :

After writing the initial bug report, I learned more about SVG paths.

A good doc source is https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths

According to that doc, a well-formed path always starts with an "M" (moveto) element, which provides the starting location for the path. The M is then followed by various other elements like "L" (lineto), "C" (curveto), etc. Those following elements tell where to go.

A path without an M could be one of two things.

1) The path could be empty - a null path - there is nothing at all inside the path "container". This is the situation that triggered the crash.

2) The path could be malformed - it has "lineto" or "curveto" elements without an initial M. That is meaningless because you need to know where you are before you can go somewhere. That might be okay if there were a notion of a stateful "current point" that persists from one path to the next, but SVG doesn't work that way; each path is self-contained.

Given that programming axiom that code should not crash in the face of empty input, I'm pretty sure that the patch is correct for case (1), which is the observed situation.

Ideally, the code should not crash for other forms of malformed input, for example a path that contains only a "Z" (close path) element, but that is somewhat harder to implement and perhaps a topic for later.