diff options
author | Erlang/OTP <otp@erlang.org> | 2021-09-02 12:15:49 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2021-09-02 12:15:49 +0200 |
commit | 4460930334a89ec2697121b82941b4a55ab843ff (patch) | |
tree | 792796822a2fe218f2765d8d3e3e37d33e46e076 | |
parent | 715b7e564ea5fbed52b52400919c0c9fc3e57dc1 (diff) | |
parent | ce10900488ac79db29655e468a8f945846181bb2 (diff) | |
download | erlang-4460930334a89ec2697121b82941b4a55ab843ff.tar.gz |
Merge branch 'lukas/erts/fix-convert-subbin-bugs/OTP-17585' into maint-22
* lukas/erts/fix-convert-subbin-bugs/OTP-17585:
erts: Make re copy small subbinaries
-rw-r--r-- | erts/emulator/beam/erl_bif_re.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_bif_re.c b/erts/emulator/beam/erl_bif_re.c index 568534cab2..a222d1116f 100644 --- a/erts/emulator/beam/erl_bif_re.c +++ b/erts/emulator/beam/erl_bif_re.c @@ -1282,7 +1282,7 @@ re_run(Process *p, Eterm arg1, Eterm arg2, Eterm arg3, int first) } /* Optimized - if already in binary off heap, keep that and avoid - copying, also binary returns can be sub binaries in that case */ + copying, also binary returns can be sub binaries in that case. */ restart.flags = 0; if (is_binary(arg1)) { @@ -1297,7 +1297,10 @@ re_run(Process *p, Eterm arg1, Eterm arg2, Eterm arg3, int first) slength = binary_size(arg1); bptr = binary_val(real_bin); - if (bitsize != 0 || bitoffs != 0 || (*bptr != HEADER_PROC_BIN)) { + if (bitsize != 0 || bitoffs != 0 || slength <= ERL_ONHEAP_BIN_LIMIT) { + /* If this is an unaligned subbinary, + or the binary is smaller than the ERL_ONHEAP_BIN_LIMIT + we make a copy of the binary. */ goto handle_iolist; } pb = (ProcBin *) bptr; |