AP_MultiHeap: initialize only if heap allocation succeeded

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
This commit is contained in:
Rhys Mainwaring 2025-01-04 19:38:59 +00:00 committed by Thomas Watson
parent 5f8a655f35
commit 94aa4fc808

View File

@ -36,9 +36,9 @@ void *MultiHeap::heap_create(uint32_t size)
{
struct heap *new_heap = (struct heap*)malloc(sizeof(struct heap));
if (new_heap != nullptr) {
new_heap->magic = HEAP_MAGIC;
new_heap->max_heap_size = size;
}
new_heap->magic = HEAP_MAGIC;
return (void *)new_heap;
}