Skip to content

Commit

Permalink
Fix bug in globalcontext_unregister_process
Browse files Browse the repository at this point in the history
The way the registered processes were freed when being unregisterd was unsafe if
future API changes requre adjusting the layout of the RegisteredProcess struct.

Signed-off-by: Winford <winford@object.stream>
  • Loading branch information
UncleGrumpy committed Jun 20, 2023
1 parent 2bf9ff0 commit 1e54393
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libAtomVM/globalcontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ bool globalcontext_unregister_process(GlobalContext *glb, int atom_index)
struct ListHead *registered_processes_list = synclist_wrlock(&glb->registered_processes);
struct ListHead *item;
LIST_FOR_EACH (item, registered_processes_list) {
const struct RegisteredProcess *registered_process = GET_LIST_ENTRY(item, struct RegisteredProcess, registered_processes_list_head);
struct RegisteredProcess *registered_process = GET_LIST_ENTRY(item, struct RegisteredProcess, registered_processes_list_head);
if (registered_process->atom_index == atom_index) {
list_remove(item);
free(item);
free(registered_process);
synclist_unlock(&glb->registered_processes);
return true;
}
Expand Down

0 comments on commit 1e54393

Please sign in to comment.