diff options
author | Björn Gustavsson <[email protected]> | 2016-09-15 10:16:28 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-09-15 10:16:28 +0200 |
commit | fde238fb52133a6c7a2a3f2a2e16f1c1bef62394 (patch) | |
tree | 0e553f298c23f508975635a121fbf8356c58ab8a /erts/emulator/beam/erl_nif.c | |
parent | cebef1207eca1cdc8c601b172988a74fd0858efa (diff) | |
parent | 359e05121dab023585715b0e42506afd94f2e1f1 (diff) | |
download | otp-fde238fb52133a6c7a2a3f2a2e16f1c1bef62394.tar.gz otp-fde238fb52133a6c7a2a3f2a2e16f1c1bef62394.tar.bz2 otp-fde238fb52133a6c7a2a3f2a2e16f1c1bef62394.zip |
Merge branch 'bjorn/erts/on_load/ERL-240/OTP-13893' into maint
* bjorn/erts/on_load/ERL-240/OTP-13893:
erts: Add nif_SUITE:t_on_load
erts: Improve nif_SUITE:upgrade test
Don't leak old code when loading a modules with an on_load function
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index 559b4017e7..3a547982da 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -3203,18 +3203,20 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) if (init_func != NULL) handle = init_func; + this_mi = &module_p->curr; + prev_mi = &module_p->old; if (in_area(caller, module_p->old.code_hdr, module_p->old.code_length)) { - if (module_p->old.code_hdr->on_load_function_ptr) { - this_mi = &module_p->old; + ret = load_nif_error(BIF_P, "old_code", "Calling load_nif from old " + "module '%T' not allowed", mod_atom); + goto error; + } else if (module_p->on_load) { + ASSERT(module_p->on_load->code_hdr->on_load_function_ptr); + if (module_p->curr.code_hdr) { prev_mi = &module_p->curr; } else { - ret = load_nif_error(BIF_P, "old_code", "Calling load_nif from old " - "module '%T' not allowed", mod_atom); - goto error; + prev_mi = &module_p->old; } - } else { - this_mi = &module_p->curr; - prev_mi = &module_p->old; + this_mi = module_p->on_load; } if (init_func == NULL && |