From bbcc64772580c8a979288791afa02d30bc476d2e Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 19 Oct 2018 21:52:15 -0500 Subject: Update aom to v1.0.0 Update aom to commit id d14c5bb4f336ef1842046089849dee4a301fbbf0. --- third_party/aom/aom_mem/aom_mem.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'third_party/aom/aom_mem/aom_mem.c') diff --git a/third_party/aom/aom_mem/aom_mem.c b/third_party/aom/aom_mem/aom_mem.c index 66a0c08de..e603fc5bf 100644 --- a/third_party/aom/aom_mem/aom_mem.c +++ b/third_party/aom/aom_mem/aom_mem.c @@ -9,8 +9,6 @@ * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ -#define __AOM_MEM_C__ - #include "aom_mem.h" #include #include @@ -18,6 +16,17 @@ #include "include/aom_mem_intrnl.h" #include "aom/aom_integer.h" +#if defined(AOM_MAX_ALLOCABLE_MEMORY) +// Returns 0 in case of overflow of nmemb * size. +static int check_size_argument_overflow(uint64_t nmemb, uint64_t size) { + const uint64_t total_size = nmemb * size; + if (nmemb == 0) return 1; + if (size > AOM_MAX_ALLOCABLE_MEMORY / nmemb) return 0; + if (total_size != (size_t)total_size) return 0; + return 1; +} +#endif + static size_t GetAlignedMallocSize(size_t size, size_t align) { return size + align - 1 + ADDRESS_STORAGE_SIZE; } @@ -40,6 +49,9 @@ static void *GetActualMallocAddress(void *const mem) { void *aom_memalign(size_t align, size_t size) { void *x = NULL; const size_t aligned_size = GetAlignedMallocSize(size, align); +#if defined(AOM_MAX_ALLOCABLE_MEMORY) + if (!check_size_argument_overflow(1, aligned_size)) return NULL; +#endif void *const addr = malloc(aligned_size); if (addr) { x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, align); @@ -64,11 +76,9 @@ void aom_free(void *memblk) { } } -#if CONFIG_HIGHBITDEPTH void *aom_memset16(void *dest, int val, size_t length) { size_t i; uint16_t *dest16 = (uint16_t *)dest; for (i = 0; i < length; i++) *dest16++ = val; return dest; } -#endif // CONFIG_HIGHBITDEPTH -- cgit v1.2.3