Skip to content

Commit

Permalink
Furi: fix crash in aligned_alloc, cleanup aligned_alloc use
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Dec 18, 2024
1 parent 5722600 commit 0e24a20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion furi/core/memmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,7 @@ void* aligned_malloc(size_t size, size_t alignment) {
}

void aligned_free(void* p) {
free(((void**)p)[-1]);
if(p) {
free(((void**)p)[-1]);
}
}
8 changes: 2 additions & 6 deletions lib/flipper_application/elf/elf_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,9 @@ void elf_file_free(ELFFile* elf) {
for(ELFSectionDict_it(it, elf->sections); !ELFSectionDict_end_p(it);
ELFSectionDict_next(it)) {
const ELFSectionDict_itref_t* itref = ELFSectionDict_cref(it);
if(itref->value.data) {
aligned_free(itref->value.data);
}
aligned_free(itref->value.data);
if(itref->value.fast_rel) {
if(itref->value.fast_rel->data) {
aligned_free(itref->value.fast_rel->data);
}
aligned_free(itref->value.fast_rel->data);
free(itref->value.fast_rel);
}
free((void*)itref->key);
Expand Down

0 comments on commit 0e24a20

Please sign in to comment.