treeform / pixie

Full-featured 2d graphics library for Nim.
MIT License
743 stars 28 forks source link

fillShapes(mask: Mask, ... does not check for pathWidth == 0 #394

Closed kwhitefoot closed 2 years ago

kwhitefoot commented 2 years ago

fillShapes(image: Image, ... checks for pathWidth == 0 and returns early when it is which avoids

"index out of bounds, the container is empty" when attempting to access coverages[0].

fillShapes(mask: Mask, ... should perform the same check.

treeform commented 2 years ago

I can reproduce the crash using an internal call:

import pixie/paths {.all.}
block:
  let
    mask = newMask(100, 100)
  mask.fillShapes(@[@[vec2(0, 0), vec2(0, 1)]], EvenOdd, NormalBlend)

Do you have a simple test case that can cause this with just the public API?

treeform commented 2 years ago

Oh I was able to make it happen:


  let
    mask = newMask(100, 100)
    pathStr = "M0 0 L0 1 L0 0 Z"
  mask.fillPath(pathStr)```
kwhitefoot commented 2 years ago

Sorry about not providing a test for it. I discovered it by inspection while browsing the code.