neatroff icon indicating copy to clipboard operation
neatroff copied to clipboard

eval: Replace int by long long int to prevent evaluation-time overflows

Open Eolien55 opened this issue 2 months ago • 0 comments

Before, when resolution was high (72000 is enough), some operations would overflow.

For example, given this roff file:

.EQ
x \(mo R
.EN

neateqn would try to figure out the spacing, and in doing so, it would use arithmetic operations that would overflow. The resulting number was thus unusable for ren_ps(), and no special spacing was output.

This merely prevents some overflows that happen during evaluation time. If the resulting number is >=2^31 after evaluation, then there'd still be an overflow.

Even though neatroff has a resolution of 720dpi by default, I believe neatroff still shouldn't overflow in such contexts.

Thank you for all the incredible software you've made.

– Elie Le Vaillant

Eolien55 avatar Apr 28 '24 20:04 Eolien55