diff options
author | Sverker Eriksson <[email protected]> | 2016-02-15 19:28:52 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2016-03-29 14:57:11 +0200 |
commit | 1c630ab8793425aed1e487d25c71b8bbd9325e8b (patch) | |
tree | 865e6d4c061741a42fee5d508ae1dcb53a94c401 /erts | |
parent | 043ab9055917a4f6d89f1fa2788079e0618928c4 (diff) | |
download | otp-1c630ab8793425aed1e487d25c71b8bbd9325e8b.tar.gz otp-1c630ab8793425aed1e487d25c71b8bbd9325e8b.tar.bz2 otp-1c630ab8793425aed1e487d25c71b8bbd9325e8b.zip |
erts: Fix bug in enif_term_to_binary
Wait until after dec_term and factory_close to do cache_env(),
otherwise we will cache the wrong state.
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index d8f2272c6d..c6ece8c1c7 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -705,19 +705,8 @@ size_t enif_binary_to_term(ErlNifEnv *dst_env, return 0; if (size > 0) { - - if (is_internal_pid(dst_env->proc->common.id)) { - flush_env(dst_env); - erts_factory_proc_prealloc_init(&factory, dst_env->proc, size); - cache_env(dst_env); - } else { - - /* this is guaranteed to create a heap fragment */ - if (!alloc_heap(dst_env, size)) - return 0; - - erts_factory_heap_frag_init(&factory, dst_env->heap_frag); - } + flush_env(dst_env); + erts_factory_proc_prealloc_init(&factory, dst_env->proc, size); } else { erts_factory_dummy_init(&factory); } @@ -728,6 +717,8 @@ size_t enif_binary_to_term(ErlNifEnv *dst_env, return 0; } erts_factory_close(&factory); + cache_env(dst_env); + ASSERT(bp > data); return bp - data; } |