aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/external.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-02-14 18:26:31 +0100
committerSverker Eriksson <[email protected]>2017-02-14 18:26:31 +0100
commit118de47d703e303aea7f4575849a37c11416ba14 (patch)
tree211bbb6c24d6069c657d3b7ac7776be45631ec48 /erts/emulator/beam/external.c
parentdd60ebfa1f2f6dc203deee59f95305291d06a619 (diff)
downloadotp-118de47d703e303aea7f4575849a37c11416ba14.tar.gz
otp-118de47d703e303aea7f4575849a37c11416ba14.tar.bz2
otp-118de47d703e303aea7f4575849a37c11416ba14.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/external.c')
-rw-r--r--erts/emulator/beam/external.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
index f9cba0aec0..205a7711ec 100644
--- a/erts/emulator/beam/external.c
+++ b/erts/emulator/beam/external.c
@@ -1398,12 +1398,13 @@ static void b2t_destroy_context(B2TContext* context)
}
}
-static void b2t_context_destructor(Binary *context_bin)
+static int b2t_context_destructor(Binary *context_bin)
{
B2TContext* ctx = (B2TContext*) ERTS_MAGIC_BIN_DATA(context_bin);
ASSERT(ERTS_MAGIC_BIN_DESTRUCTOR(context_bin) == b2t_context_destructor);
b2t_destroy_context(ctx);
+ return 1;
}
static BIF_RETTYPE binary_to_term_trap_1(BIF_ALIST_1)
@@ -1808,7 +1809,7 @@ erts_term_to_binary(Process* p, Eterm Term, int level, Uint flags) {
#endif
#define TERM_TO_BINARY_MEMCPY_FACTOR 8
-static void ttb_context_destructor(Binary *context_bin)
+static int ttb_context_destructor(Binary *context_bin)
{
TTBContext *context = ERTS_MAGIC_BIN_DATA(context_bin);
if (context->alive) {
@@ -1842,6 +1843,7 @@ static void ttb_context_destructor(Binary *context_bin)
break;
}
}
+ return 1;
}
static Eterm erts_term_to_binary_int(Process* p, Eterm Term, int level, Uint flags,