diff --git a/rtc_base/memory/BUILD.gn b/rtc_base/memory/BUILD.gn index 3f70fca819..1e3eb08b02 100644 --- a/rtc_base/memory/BUILD.gn +++ b/rtc_base/memory/BUILD.gn @@ -27,7 +27,9 @@ rtc_source_set("aligned_malloc") { "aligned_malloc.cc", "aligned_malloc.h", ] - deps = [] + deps = [ + "..:checks", + ] } rtc_source_set("fifo_buffer") { diff --git a/rtc_base/memory/aligned_malloc.cc b/rtc_base/memory/aligned_malloc.cc index c893c96ef2..5de8dabb09 100644 --- a/rtc_base/memory/aligned_malloc.cc +++ b/rtc_base/memory/aligned_malloc.cc @@ -10,6 +10,8 @@ #include "rtc_base/memory/aligned_malloc.h" +#include "rtc_base/checks.h" + #include // for free, malloc #include // for memcpy @@ -61,9 +63,7 @@ void* AlignedMalloc(size_t size, size_t alignment) { // A pointer to the start of the memory must be stored so that it can be // retreived for deletion, ergo the sizeof(uintptr_t). void* memory_pointer = malloc(size + sizeof(uintptr_t) + alignment - 1); - if (memory_pointer == NULL) { - return NULL; - } + RTC_CHECK(memory_pointer) << "Couldn't allocate memory in AlignedMalloc"; // Aligning after the sizeof(uintptr_t) bytes will leave room for the header // in the same memory block.