Skip to content

Commit 76cc2dc

Browse files
committed
Fix crash when loading module fails, for example because of OOM
Setting `module_platform_data` to NULL is not necessary as it's done by `module_new_from_iff_binary` which memsets the structure to 0. On the contrary, if `module_new_from_iff_binary` returns NULL it would crash. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent f660ded commit 76cc2dc

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/libAtomVM/globalcontext.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,7 @@ Module *globalcontext_load_module_from_avm(GlobalContext *global, const char *mo
687687
return NULL;
688688
}
689689

690-
Module *new_module = module_new_from_iff_binary(global, beam_module, beam_module_size);
691-
new_module->module_platform_data = NULL;
692-
693-
return new_module;
690+
return module_new_from_iff_binary(global, beam_module, beam_module_size);
694691
}
695692

696693
Module *globalcontext_get_module(GlobalContext *global, AtomString module_name_atom)

0 commit comments

Comments
 (0)