diff options
author | volzhs <volzhs@gmail.com> | 2016-12-22 09:54:15 +0900 |
---|---|---|
committer | volzhs <volzhs@gmail.com> | 2016-12-24 00:46:09 +0900 |
commit | e04c7e11ec2fabf34aaf515103bc0b6086e1aabd (patch) | |
tree | 7e8e1947eb71efe8bf45632610ee2776c9ef0b3e /thirdparty/libwebp/utils | |
parent | 2c8a1729152f5bcb1cb81d24b1e642634bff7174 (diff) |
Update libwebp to 0.5.2
Diffstat (limited to 'thirdparty/libwebp/utils')
-rw-r--r-- | thirdparty/libwebp/utils/rescaler.c | 8 | ||||
-rw-r--r-- | thirdparty/libwebp/utils/utils.c | 8 | ||||
-rw-r--r-- | thirdparty/libwebp/utils/utils.h | 10 |
3 files changed, 21 insertions, 5 deletions
diff --git a/thirdparty/libwebp/utils/rescaler.c b/thirdparty/libwebp/utils/rescaler.c index 00c9300bfb..d2278a52ff 100644 --- a/thirdparty/libwebp/utils/rescaler.c +++ b/thirdparty/libwebp/utils/rescaler.c @@ -48,11 +48,15 @@ void WebPRescalerInit(WebPRescaler* const wrk, int src_width, int src_height, wrk->y_sub = wrk->y_expand ? y_sub - 1 : y_sub; wrk->y_accum = wrk->y_expand ? wrk->y_sub : wrk->y_add; if (!wrk->y_expand) { - // this is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast. + // 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); if (ratio != (uint32_t)ratio) { - // We can't represent the ratio with the current fixed-point precision. + // When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the + // current fixed-point precision. This happens when src_height == + // wrk->y_add (which == src_height), and wrk->x_add == 1. // => We special-case fxy_scale = 0, in WebPRescalerExportRow(). wrk->fxy_scale = 0; } else { diff --git a/thirdparty/libwebp/utils/utils.c b/thirdparty/libwebp/utils/utils.c index 2602ca3c9f..82dbf8d5e5 100644 --- a/thirdparty/libwebp/utils/utils.c +++ b/thirdparty/libwebp/utils/utils.c @@ -175,8 +175,12 @@ static int CheckSizeArgumentsOverflow(uint64_t nmemb, size_t size) { } #endif #if defined(MALLOC_LIMIT) - if (mem_limit > 0 && total_mem + total_size >= mem_limit) { - return 0; // fake fail! + if (mem_limit > 0) { + const uint64_t new_total_mem = (uint64_t)total_mem + total_size; + if (new_total_mem != (size_t)new_total_mem || + new_total_mem > mem_limit) { + return 0; // fake fail! + } } #endif diff --git a/thirdparty/libwebp/utils/utils.h b/thirdparty/libwebp/utils/utils.h index e0a81126df..3a5d4e6a78 100644 --- a/thirdparty/libwebp/utils/utils.h +++ b/thirdparty/libwebp/utils/utils.h @@ -20,6 +20,7 @@ #endif #include <assert.h> +#include <limits.h> #include "../dsp/dsp.h" #include "../webp/types.h" @@ -32,7 +33,14 @@ extern "C" { // Memory allocation // This is the maximum memory amount that libwebp will ever try to allocate. -#define WEBP_MAX_ALLOCABLE_MEMORY (1ULL << 40) +#ifndef WEBP_MAX_ALLOCABLE_MEMORY +#if SIZE_MAX > (1ULL << 34) +#define WEBP_MAX_ALLOCABLE_MEMORY (1ULL << 34) +#else +// For 32-bit targets keep this below INT_MAX to avoid valgrind warnings. +#define WEBP_MAX_ALLOCABLE_MEMORY ((1ULL << 31) - (1 << 16)) +#endif +#endif // WEBP_MAX_ALLOCABLE_MEMORY // size-checking safe malloc/calloc: verify that the requested size is not too // large, or return NULL. You don't need to call these for constructs like |