diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index f0ef82f3fda..8075113e6ad 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -146,12 +146,16 @@ static inline void *mem_heap_zalloc(mem_heap_t *heap, ulint n) { @param[in] n number of bytes; if the heap is allowed to grow into the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF @return allocated storage, NULL if did not succeed (only possible for -MEM_HEAP_BTR_SEARCH type heaps) */ +MEM_HEAP_BTR_SEARCH type heaps) or n is 0. */ static inline void *mem_heap_alloc(mem_heap_t *heap, ulint n) { mem_block_t *block; byte *buf; ulint free; + if (n == 0) { + return (nullptr); + } + ut_d(mem_block_validate(heap)); block = UT_LIST_GET_LAST(heap->base);