Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on undefined controlPoint with specific precision setting #2077

Closed
virtulis opened this issue Sep 26, 2024 · 1 comment
Closed

Crash on undefined controlPoint with specific precision setting #2077

virtulis opened this issue Sep 26, 2024 · 1 comment
Labels

Comments

@virtulis
Copy link

Describe the bug
This specific SVG causes a crash to happen specifically when floatPrecision: 2 is set. Only this SVG, only this value.
Might be related to the note in #1927 and seems to be a rather rare occurrence indeed.

SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/plugins/convertPathData.js:1160
  return [2 * base[0] - controlPoint[0], 2 * base[1] - controlPoint[1]];
                                    ^

TypeError: Cannot read properties of undefined (reading '0')
    at reflectPoint (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/plugins/convertPathData.js:1160:37)
    at SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/plugins/convertPathData.js:802:43
    at Array.filter (<anonymous>)
    at filters (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/plugins/convertPathData.js:397:15)
    at Object.enter (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/plugins/convertPathData.js:183:20)
    at visit (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/lib/xast.js:52:30)
    at visit (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/lib/xast.js:68:9)
    at visit (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/lib/xast.js:61:7)
    at invokePlugins (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/lib/svgo/plugins.js:25:7)
    at Object.fn (SNIP/svgo/node_modules/.pnpm/[email protected]/node_modules/svgo/lib/svgo/plugins.js:57:7)

crash

To Reproduce

svgo crash.svg -o test.svg --precision 2

or

const orig = await readFile("crash.svg", "utf-8");
const opt = optimize(orig, {
  floatPrecision: 2,
});

Expected behavior
SVG is optimized.

Desktop (please complete the following information):

  • SVGO Version 3.3.2
  • NodeJs Version 22.9.0
  • OS: Linux (multiple)

Additional context
The SVG itself is output of pdf2svg on a PDF, I believe.

@virtulis virtulis added the bug label Sep 26, 2024
@virtulis
Copy link
Author

virtulis commented Sep 26, 2024

Sorry I read the comments and saw this was reverted. Will fall back to 3.3.1 for now.

@virtulis virtulis closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant