VP8LAllocateHistogramSet: fix overflow in size calculation
the multiplications done for total_size would be done with integers, possibly overflowing, before being promoted to 64-bit for the addition Change-Id: Id5c127c8a497ce5de89a276c17f36b59eeb67c21
This commit is contained in:
parent
a792b913bd
commit
a6ae04d455
@ -55,9 +55,9 @@ VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits) {
|
||||
int i;
|
||||
VP8LHistogramSet* set;
|
||||
VP8LHistogram* bulk;
|
||||
const uint64_t total_size = (uint64_t)sizeof(*set)
|
||||
+ size * sizeof(*set->histograms)
|
||||
+ size * sizeof(**set->histograms);
|
||||
const uint64_t total_size = sizeof(*set)
|
||||
+ (uint64_t)size * sizeof(*set->histograms)
|
||||
+ (uint64_t)size * sizeof(**set->histograms);
|
||||
uint8_t* memory = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*memory));
|
||||
if (memory == NULL) return NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user