summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2021-09-02 12:15:49 +0200
committerErlang/OTP <otp@erlang.org>2021-09-02 12:15:49 +0200
commit4460930334a89ec2697121b82941b4a55ab843ff (patch)
tree792796822a2fe218f2765d8d3e3e37d33e46e076
parent715b7e564ea5fbed52b52400919c0c9fc3e57dc1 (diff)
parentce10900488ac79db29655e468a8f945846181bb2 (diff)
downloaderlang-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.c7
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;