Commit 89553a3
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 f71cf50 commit 89553a3
2 files changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3547 | 3547 | | |
3548 | 3548 | | |
3549 | 3549 | | |
3550 | | - | |
| 3550 | + | |
3551 | 3551 | | |
3552 | 3552 | | |
3553 | 3553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4912 | 4912 | | |
4913 | 4913 | | |
4914 | 4914 | | |
| 4915 | + | |
| 4916 | + | |
| 4917 | + | |
| 4918 | + | |
| 4919 | + | |
| 4920 | + | |
| 4921 | + | |
4915 | 4922 | | |
4916 | 4923 | | |
4917 | 4924 | | |
| |||
0 commit comments