Skip to content

Commit 94aa4fc

Browse files
srmainwaringtpwrules
authored andcommitted
AP_MultiHeap: initialize only if heap allocation succeeded
Signed-off-by: Rhys Mainwaring <[email protected]>
1 parent 5f8a655 commit 94aa4fc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/AP_MultiHeap/MultiHeap_malloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ void *MultiHeap::heap_create(uint32_t size)
3636
{
3737
struct heap *new_heap = (struct heap*)malloc(sizeof(struct heap));
3838
if (new_heap != nullptr) {
39+
new_heap->magic = HEAP_MAGIC;
3940
new_heap->max_heap_size = size;
4041
}
41-
new_heap->magic = HEAP_MAGIC;
4242
return (void *)new_heap;
4343
}
4444

0 commit comments

Comments
 (0)