aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-03-01 10:36:39 +0100
committerLukas Larsson <[email protected]>2017-03-01 10:36:39 +0100
commit55f203d6af5cebee168814a8f57f4b2273fa2878 (patch)
treebd067c71fae1e762b536bd1a570389b1498522da /erts/emulator
parent52f822ab407be031a0013f47ff2b1b45b27fc1f5 (diff)
parentcfe4b5c4aaa0d86f9d98095515ae6582a053cc47 (diff)
downloadotp-55f203d6af5cebee168814a8f57f4b2273fa2878.tar.gz
otp-55f203d6af5cebee168814a8f57f4b2273fa2878.tar.bz2
otp-55f203d6af5cebee168814a8f57f4b2273fa2878.zip
Merge branch 'lukas/erts/port_control_emasculate_binary/OTP-14231' into maint
* lukas/erts/port_control_emasculate_binary/OTP-14231: erts: Fix emasculation of binaries in port_control
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/io.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index 9bf29ee230..38e403d91a 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -4889,10 +4889,18 @@ erts_port_control(Process* c_p,
copy = 1;
else {
ProcBin *pb = (ProcBin *) ebinp;
+ int offset = bufp - pb->val->orig_bytes;
- if (pb->flags)
+ ASSERT(pb->val->orig_bytes <= bufp
+ && bufp + size <= pb->val->orig_bytes + pb->val->orig_size);
+
+ if (pb->flags) {
erts_emasculate_writable_binary(pb);
+ /* The procbin may have been reallocated, so update bufp */
+ bufp = pb->val->orig_bytes + offset;
+ }
+
binp = pb->val;
ASSERT(bufp <= bufp + size);
ASSERT(binp->orig_bytes <= bufp