diff options
author | Lukas Larsson <[email protected]> | 2017-03-28 10:31:55 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2017-03-28 10:31:55 +0200 |
commit | 3eb01a8b3c02910495ccf69921f48c606b44361f (patch) | |
tree | 060550ba99eb053d4a7928178954724fe8bc7b26 /erts/emulator/beam | |
parent | 2a24d08dbb9188cb4c3ee07c92ff5c09bba6c5e3 (diff) | |
parent | 7488cfc986e1608e73f904071556eb0543d6a346 (diff) | |
download | otp-3eb01a8b3c02910495ccf69921f48c606b44361f.tar.gz otp-3eb01a8b3c02910495ccf69921f48c606b44361f.tar.bz2 otp-3eb01a8b3c02910495ccf69921f48c606b44361f.zip |
Merge branch 'lukas/erts/fix_enif_inspect_binary_emasculate/OTP-14304'
* lukas/erts/fix_enif_inspect_binary_emasculate/OTP-14304:
erts: Add enif_inspect_binary emasculation of refc bins
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index e6da4c1a76..63a4a997da 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -998,16 +998,14 @@ int enif_inspect_binary(ErlNifEnv* env, Eterm bin_term, ErlNifBinary* bin) 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; - } - } + if (is_binary(bin_term)) { + ProcBin *pb = (ProcBin*) binary_val(bin_term); + if (pb->thing_word == HEADER_SUB_BIN) { + ErlSubBin* sb = (ErlSubBin*) pb; + pb = (ProcBin*) binary_val(sb->orig); + } + if (pb->thing_word == HEADER_PROC_BIN && pb->flags) + erts_emasculate_writable_binary(pb); } u.tmp = NULL; bin->data = erts_get_aligned_binary_bytes_extra(bin_term, &u.raw_ptr, allocator, @@ -1024,7 +1022,7 @@ int enif_inspect_binary(ErlNifEnv* env, Eterm bin_term, ErlNifBinary* bin) bin->bin_term = bin_term; bin->size = binary_size(bin_term); bin->ref_bin = NULL; - ADD_READONLY_CHECK(env, bin->data, bin->size); + ADD_READONLY_CHECK(env, bin->data, bin->size); return 1; } |