Merge "VP8LAllocateHistogramSet: fix overflow in size calculation"

This commit is contained in:
pascal massimino 2012-10-03 14:57:15 -07:00 committed by Gerrit Code Review
commit ce8bff45bc

View File

@ -55,9 +55,9 @@ VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits) {
int i; int i;
VP8LHistogramSet* set; VP8LHistogramSet* set;
VP8LHistogram* bulk; VP8LHistogram* bulk;
const uint64_t total_size = (uint64_t)sizeof(*set) const uint64_t total_size = sizeof(*set)
+ size * sizeof(*set->histograms) + (uint64_t)size * sizeof(*set->histograms)
+ size * sizeof(**set->histograms); + (uint64_t)size * sizeof(**set->histograms);
uint8_t* memory = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*memory)); uint8_t* memory = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*memory));
if (memory == NULL) return NULL; if (memory == NULL) return NULL;