nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.84k stars 7.72k forks source link

stb_truetype: division by 0 in stbtt__fill_active_edges_new() #1316

Open ocornut opened 2 years ago

ocornut commented 2 years ago

Describe the bug Apparently there's a division by zero in stbtt__fill_active_edges_new() on that line:

dy = (y_final - y_crossing ) / (x2 - (x1+1)); // if denom=0, y_final = y_crossing, so y_final <= y_bottom

See: https://github.com/ocornut/imgui/issues/5139

To Reproduce I am sorry I do not have a repro yet. This was reported by @mgerhardy and I am waiting on their answer. I tried loading a few fonts with an extra assert and it didn't trigger for me.

Martin proposed fix is https://github.com/mgerhardy/vengi/commit/a337ecaeb5ae47cfcc462d8f91a38199a41fa199 but I haven't looked at the code so know if it makes sense.

nothings commented 2 years ago

I believe the suggested fix is fine, as the 0 case should mean there will be no further use of dy anyway.

nothings commented 2 years ago

I've fixed this locally, but I don't know when the next release will be.

ocornut commented 2 years ago

Thank you Sean. (I've pushed the same fix on our own copy too now).