diff options
author | Erlang/OTP <otp@erlang.org> | 2021-09-02 12:21:04 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2021-09-02 12:21:04 +0200 |
commit | 010d6b1d0aa6201fc12e28f8eae4ae704d690db8 (patch) | |
tree | e40fcc8a467a28c0282575ee5ce6b22793253ce3 | |
parent | ade2a1bfd4b27c9a0a9eaa8f15cce02b2bd51548 (diff) | |
parent | ce10900488ac79db29655e468a8f945846181bb2 (diff) | |
download | erlang-010d6b1d0aa6201fc12e28f8eae4ae704d690db8.tar.gz |
Merge branch 'lukas/erts/fix-convert-subbin-bugs/OTP-17585' into maint-24
* 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 ae0bc2ebe2..53634afcfe 100644 --- a/erts/emulator/beam/erl_bif_re.c +++ b/erts/emulator/beam/erl_bif_re.c @@ -1285,7 +1285,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)) { @@ -1300,7 +1300,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; |