summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-02-09 16:24:03 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-02-09 16:24:03 +0000
commit455d824a47f78dd5ff51a248ef7718d109d66a87 (patch)
tree11c20b9ca6f5e47b72995b58e061673455fba1da /op.c
parentfb55449c820151ec18475c38cc3361fa88eb0a1b (diff)
downloadperl-455d824a47f78dd5ff51a248ef7718d109d66a87.tar.gz
Integrate changes #8704,8710 from pureperl.
Fixed UMRs and leak in Perl_pmtrans() Several leaks an UMRs fixed, mainly in the area of Perl_pmtrans and associated UTFied tr/// code. Also fixed scoping leak of PL_reg_start_tmp. p4raw-link: @8710 on //depot/maint-5.6/pureperl: 4b295d51b64a7a209f5040a76fc8fbb310bcc094 p4raw-link: @8704 on //depot/maint-5.6/pureperl: a0f842d35079c52aadb60790fe59b37d9727c9a9 p4raw-id: //depot/perl@8735 p4raw-integrated: from //depot/maint-5.6/pureperl@8734 'edit in' op.c (@8704..) 'merge in' regcomp.c (@8694..)
Diffstat (limited to 'op.c')
-rw-r--r--op.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/op.c b/op.c
index 95a72fc6b0..379d7e9ebf 100644
--- a/op.c
+++ b/op.c
@@ -2693,7 +2693,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
while (t < tend) {
cp[i++] = t;
t += UTF8SKIP(t);
- if (*t == 0xff) {
+ if (t < tend && *t == 0xff) {
t++;
t += UTF8SKIP(t);
}
@@ -2701,7 +2701,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
qsort(cp, i, sizeof(U8*), utf8compare);
for (j = 0; j < i; j++) {
U8 *s = cp[j];
- I32 cur = j < i ? cp[j+1] - s : tend - s;
+ I32 cur = j < i - 1 ? cp[j+1] - s : tend - s;
UV val = utf8_to_uv(s, cur, &ulen, 0);
s += ulen;
diff = val - nextmin;
@@ -2714,7 +2714,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
sv_catpvn(transv, (char*)tmpbuf, t - tmpbuf);
}
}
- if (*s == 0xff)
+ if (s < tend && *s == 0xff)
val = utf8_to_uv(s+1, cur - 1, &ulen, 0);
if (val >= nextmin)
nextmin = val + 1;
@@ -2727,6 +2727,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
t = (U8*)SvPVX(transv);
tlen = SvCUR(transv);
tend = t + tlen;
+ Safefree(cp);
}
else if (!rlen && !del) {
r = t; rlen = tlen; rend = tend;
@@ -2819,6 +2820,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
else
bits = 8;
+ Safefree(cPVOPo->op_pv);
cSVOPo->op_sv = (SV*)swash_init("utf8", "", listsv, bits, none);
SvREFCNT_dec(listsv);
if (transv)