diff options
author | Erlang/OTP <otp@erlang.org> | 2021-09-02 12:45:16 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2021-09-02 12:45:16 +0200 |
commit | 751cd304240b2d7e1f69ab1fc39e44791e94f741 (patch) | |
tree | fc2f30df44b09bfecfa33de7b4170b8497f25652 | |
parent | 6a0ad7a29291c8d00519a45b108e693ad8e7d6cf (diff) | |
parent | ce10900488ac79db29655e468a8f945846181bb2 (diff) | |
download | erlang-751cd304240b2d7e1f69ab1fc39e44791e94f741.tar.gz |
Merge branch 'lukas/erts/fix-convert-subbin-bugs/OTP-17585' into maint-23
* 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 0428b4e348..4879c83fd4 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; |