aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2018-05-15 20:42:46 +0200
committerSverker Eriksson <[email protected]>2018-05-16 14:22:35 +0200
commitd7bacbc798d608f259eb2faaaf194cb9df323018 (patch)
tree3f83cbd4c488c99322189ff8431e9ab60fb39848 /erts/emulator/beam
parentda06fd040775fffee17409ebbd6fa797e34d6f99 (diff)
downloadotp-d7bacbc798d608f259eb2faaaf194cb9df323018.tar.gz
otp-d7bacbc798d608f259eb2faaaf194cb9df323018.tar.bz2
otp-d7bacbc798d608f259eb2faaaf194cb9df323018.zip
erts: Fix bug in enif_binary_to_term for immediates
Symptom: Heap corruption Expanded test case to provoke this bug and test some more term types.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/erl_nif.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 479a2f4809..a41145af41 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1157,8 +1157,10 @@ size_t enif_binary_to_term(ErlNifEnv *dst_env,
if (is_non_value(*term)) {
return 0;
}
- erts_factory_close(&factory);
- cache_env(dst_env);
+ if (size > 0) {
+ erts_factory_close(&factory);
+ cache_env(dst_env);
+ }
ASSERT(bp > data);
return bp - data;