diff options
author | Sverker Eriksson <[email protected]> | 2017-02-03 15:22:48 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-02-03 17:23:35 +0100 |
commit | 3fe6f3c0caecec522c7e14353eda6bbb86c9e8d6 (patch) | |
tree | 29710e0dcc08a4798d61027f2f7762a0fc275ad8 /erts/emulator/beam/erl_nif.c | |
parent | 69b928b12d9206d00879c08e46143f599f9dc34e (diff) | |
download | otp-3fe6f3c0caecec522c7e14353eda6bbb86c9e8d6.tar.gz otp-3fe6f3c0caecec522c7e14353eda6bbb86c9e8d6.tar.bz2 otp-3fe6f3c0caecec522c7e14353eda6bbb86c9e8d6.zip |
erts: Add deallocation veto for magic destructors
A magic destructor can return 0 and thereby take control
and prolong the lifetime of a magic binary.
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index 85fa53a886..fbe94708a5 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -2109,7 +2109,7 @@ static void rollback_opened_resource_types(void) } -static void nif_resource_dtor(Binary* bin) +static int nif_resource_dtor(Binary* bin) { ErlNifResource* resource = (ErlNifResource*) ERTS_MAGIC_BIN_UNALIGNED_DATA(bin); ErlNifResourceType* type = resource->type; @@ -2128,6 +2128,7 @@ static void nif_resource_dtor(Binary* bin) steal_resource_type(type); erts_free(ERTS_ALC_T_NIF, type); } + return 1; } void erts_resource_stop(ErlNifResource* resource, ErlNifEvent e, |