memononen / nanosvg

Simple stupid SVG parser
zlib License
1.69k stars 357 forks source link

Division by float 0 #179

Closed qarmin closed 3 years ago

qarmin commented 4 years ago
thirdparty/nanosvg/nanosvg.h:2161:49: runtime error: division by zero

https://github.com/memononen/nanosvg/blob/25241c5a8f8451d41ab1b02ab2d865b01600d949/src/nanosvg.h#L2161

not sure about reproduction steps

SergeySlice commented 3 years ago

I resolved this in such a way

  if ((hda < 1e-3f) && (hda > -1e-3f)) hda *= 0.5f;
  else hda = (1.0f - cosf(hda)) / sinf(hda);
  kappa = fabsf(4.0f / 3.0f * hda);
oehhar commented 3 years ago

Sergey, thanks for the proposed fix. Should I prepare a pull request and bring it to th attention of memononen ?

Thank you, Harald