fix: Avoid a signed left shift by 31 in `png_muldiv`
In builds without floating point arithmetic, `png_muldiv` accumulates
the quotient in a signed `png_fixed_point` and adds `1<<bitshift` for
`bitshift` up to 31. Shifting 1 into the sign bit of an `int` is
undefined behavior, and the following increment and negation can
overflow as well.
Accumulate the quotient in a `png_uint_32` and range-check it before
converting it to `png_fixed_point`. Results are unchanged where the old
code was defined.
This is a cherry-pick of commit 6b30e6cfa25d3029620ba3843fa08b2e15463f1f
from branch 'libpng18'.
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2 files changed