Commit 2d66a3a
committed
sv_setsv_cow: apply the same tests we do for a normal COW copy
Previously if you had a successful match against an SV with a
SvLEN() large relative to the SvCUR() the regexp engine would
use sv_setsv_cow() to make a COW copy of the matched SV,
extending the life of the large allocation buffer.
A normal sv_setsv() normally didn't do such a COW copy, but the above
also marked the source SV as COW, so further copies of the SV
could even further extend the lifetime of the buffer, eg:
while (<>) { # readline tends to make large SvLEN()
/something/; # some sort of match
push @save, $_; # with a successful match, the large $_ buffer
# survives until @save is released
}
Fixes part of #218771 parent ba90231 commit 2d66a3a
2 files changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3572 | 3572 | | |
3573 | 3573 | | |
3574 | 3574 | | |
3575 | | - | |
| 3575 | + | |
3576 | 3576 | | |
3577 | 3577 | | |
3578 | 3578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4927 | 4927 | | |
4928 | 4928 | | |
4929 | 4929 | | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
| 4933 | + | |
| 4934 | + | |
| 4935 | + | |
| 4936 | + | |
4930 | 4937 | | |
4931 | 4938 | | |
4932 | 4939 | | |
| |||
0 commit comments