mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
WebPRescalerInit: add missing int64_t promotion
large values of x_add and y_add may rollover an int causing a later assertion to fail in WebPRescalerExportRow due to fxy_scale incorrectly being set to 0. fixes: src/dsp/rescaler.c:178: void WebPRescalerExportRow(WebPRescaler *const): Assertion `wrk->src_height == wrk->dst_height && wrk->x_add == 1' failed. Bug: chromium:1196480 Change-Id: I2c00f015d61a1257033d8edb1edd4d060d6878b7
This commit is contained in:
parent
b6cf52d5b8
commit
6a9916d734
@ -51,8 +51,9 @@ void WebPRescalerInit(WebPRescaler* const wrk, int src_width, int src_height,
|
||||
// This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
|
||||
// Its value is <= WEBP_RESCALER_ONE, because dst_height <= wrk->y_add, and
|
||||
// wrk->x_add >= 1;
|
||||
const uint64_t ratio =
|
||||
(uint64_t)dst_height * WEBP_RESCALER_ONE / (wrk->x_add * wrk->y_add);
|
||||
const uint64_t num = (uint64_t)dst_height * WEBP_RESCALER_ONE;
|
||||
const uint64_t den = (uint64_t)wrk->x_add * wrk->y_add;
|
||||
const uint64_t ratio = num / den;
|
||||
if (ratio != (uint32_t)ratio) {
|
||||
// When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the
|
||||
// current fixed-point precision. This happens when src_height ==
|
||||
|
Loading…
Reference in New Issue
Block a user