mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 02:07:09 -06:00
moveto, lineto and curveto check that the current path holds fewer than 1,048,576 elements before they add one, and they stop the reading with "a path has too many points" when it is full. closepath added its element without that check. In an encoded user path, a byte of 255 runs the next operator 223 times. vectorcraft-cli info on a 622-byte file with one uappend that runs closepath 11,150,000 times peaked at a memory footprint of 601.9 MiB and reported "the file draws nothing". The string operator makes strings of up to 4 MiB, and one uappend of an operator string that long would add about 468 million elements of 56 bytes, about 24 GiB. closepath now makes the same check before it adds its element, in the closepath operator and in the ClosePath arm of append_user. On the file above, the reading now stops with "a path has too many points", and vectorcraft-cli info peaks at 62.0 MiB. A path below the limit closes as before. Tests: a moveto followed by 1,100,000 closepaths, and a uappend that runs closepath 1,059,250 times, are each read between two squares. Each reading stops with "a path has too many points" and keeps only the first square.