aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-09-04 16:59:41 +0200
committerSverker Eriksson <[email protected]>2014-09-04 16:59:41 +0200
commit267cf6cd5ba5e4392718c3c6f7f6467ac01ea2b0 (patch)
tree97f285eeac2f25d9563d4082c15020be9b90f1e2 /erts/emulator/beam/erl_nif.c
parente036643fbd5c5cba7f652734966570fee7ca99b3 (diff)
parentb182aa2cfab793e566c92183c361e78f4d6f84cb (diff)
downloadotp-267cf6cd5ba5e4392718c3c6f7f6467ac01ea2b0.tar.gz
otp-267cf6cd5ba5e4392718c3c6f7f6467ac01ea2b0.tar.bz2
otp-267cf6cd5ba5e4392718c3c6f7f6467ac01ea2b0.zip
Merge branch 'sverk/nif-inspect-copy-bug/OTP-9828' into maint
* sverk/nif-inspect-copy-bug/OTP-9828: erts: Fix bug with enif_make_copy reallocating writable binary Conflicts: erts/emulator/test/nif_SUITE.erl
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 1414744763..1caea6dcf8 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -472,6 +472,18 @@ int enif_inspect_binary(ErlNifEnv* env, Eterm bin_term, ErlNifBinary* bin)
struct enif_tmp_obj_t* tmp;
byte* raw_ptr;
}u;
+
+ if (is_boxed(bin_term) && *binary_val(bin_term) == HEADER_SUB_BIN) {
+ ErlSubBin* sb = (ErlSubBin*) binary_val(bin_term);
+ if (sb->is_writable) {
+ ProcBin* pb = (ProcBin*) binary_val(sb->orig);
+ ASSERT(pb->thing_word == HEADER_PROC_BIN);
+ if (pb->flags) {
+ erts_emasculate_writable_binary(pb);
+ sb->is_writable = 0;
+ }
+ }
+ }
u.tmp = NULL;
bin->data = erts_get_aligned_binary_bytes_extra(bin_term, &u.raw_ptr, allocator,
sizeof(struct enif_tmp_obj_t));