neatroff
neatroff copied to clipboard
eval: Replace int by long long int to prevent evaluation-time overflows
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