mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
fix a potential overflow with MALLOC_LIMIT
BUG=webp:321
Change-Id: Iab89dfe167fb394fcdffd3b2732d4ac9bef764b0
(cherry picked from commit 76bbcf2ed6
)
This commit is contained in:
parent
218460cdd7
commit
df780e0eac
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user