diff options
author | Björn Gustavsson <[email protected]> | 2012-11-08 15:41:19 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-11-08 15:41:19 +0100 |
commit | 8a3e11e386c216ad3c122f241b3758596de2ff32 (patch) | |
tree | 24e23ef62604ded2114ef76371d72182c6f67f00 /erts/emulator/beam | |
parent | 7335fe7d487210cf7126edcb11515c7879bf2e1c (diff) | |
parent | 793dd44c6cdb892de9d1b44694fd4069726030cc (diff) | |
download | otp-8a3e11e386c216ad3c122f241b3758596de2ff32.tar.gz otp-8a3e11e386c216ad3c122f241b3758596de2ff32.tar.bz2 otp-8a3e11e386c216ad3c122f241b3758596de2ff32.zip |
Merge branch 'bjorn/erts/binary-append/OTP-10524' into maint
* bjorn/erts/binary-append/OTP-10524:
Fix binary append exceptions
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/erl_bits.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/erts/emulator/beam/erl_bits.c b/erts/emulator/beam/erl_bits.c index 6bc227eeda..3753b618e1 100644 --- a/erts/emulator/beam/erl_bits.c +++ b/erts/emulator/beam/erl_bits.c @@ -1247,6 +1247,12 @@ erts_bs_append(Process* c_p, Eterm* reg, Uint live, Eterm build_size_term, */ erts_bin_offset = 8*sb->size + sb->bitsize; + if (unit > 1) { + if ((unit == 8 && (erts_bin_offset & 7) != 0) || + (erts_bin_offset % unit) != 0) { + goto badarg; + } + } used_size_in_bits = erts_bin_offset + build_size_in_bits; sb->is_writable = 0; /* Make sure that no one else can write. */ pb->size = NBYTES(used_size_in_bits); @@ -1316,6 +1322,12 @@ erts_bs_append(Process* c_p, Eterm* reg, Uint live, Eterm build_size_term, */ ERTS_GET_BINARY_BYTES(bin, src_bytes, bitoffs, bitsize); erts_bin_offset = 8*binary_size(bin) + bitsize; + if (unit > 1) { + if ((unit == 8 && (erts_bin_offset & 7) != 0) || + (erts_bin_offset % unit) != 0) { + goto badarg; + } + } used_size_in_bits = erts_bin_offset + build_size_in_bits; used_size_in_bytes = NBYTES(used_size_in_bits); bin_size = 2*used_size_in_bytes; @@ -1363,12 +1375,6 @@ erts_bs_append(Process* c_p, Eterm* reg, Uint live, Eterm build_size_term, /* * Now copy the data into the binary. */ - if (unit > 1) { - if ((unit == 8 && (erts_bin_offset & 7) != 0) || - (erts_bin_offset % unit) != 0) { - return THE_NON_VALUE; - } - } copy_binary_to_buffer(erts_current_bin, 0, src_bytes, bitoffs, erts_bin_offset); return make_binary(sb); |