summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorAaron Crane <arc@cpan.org>2017-01-24 23:39:40 +0000
committerDavid Mitchell <davem@iabyn.com>2017-02-27 12:14:59 +0000
commit41b1e858a075694f88057b9514f5fc78c80b5355 (patch)
treedae183bcdb92d5e4c5d9b8ab2709a5108e1ca5e2 /pp.c
parent78e4f28fec5bf0c2d3d8edbbd73ac68db3308f05 (diff)
downloadperl-41b1e858a075694f88057b9514f5fc78c80b5355.tar.gz
RT#130624: heap-use-after-free in 4-arg substr
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index 62316fc8b4..a640995e31 100644
--- a/pp.c
+++ b/pp.c
@@ -3396,8 +3396,10 @@ PP(pp_substr)
tmps = SvPV_force_nomg(sv, curlen);
if (DO_UTF8(repl_sv) && repl_len) {
if (!DO_UTF8(sv)) {
+ /* Upgrade the dest, and recalculate tmps in case the buffer
+ * got reallocated; curlen may also have been changed */
sv_utf8_upgrade_nomg(sv);
- curlen = SvCUR(sv);
+ tmps = SvPV_nomg(sv, curlen);
}
}
else if (DO_UTF8(sv))