summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-04-13 22:20:46 +0300
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-04-14 16:11:19 +0000
commit794a0d33eec8a6056eaa14b2e6eae594c8004a65 (patch)
tree90c6a1066554dadfa0adfcb560a6b601e9a14953 /doop.c
parent1242dfaee525d4d0ab20ac8ae62b3f0de03fa88e (diff)
downloadperl-794a0d33eec8a6056eaa14b2e6eae594c8004a65.tar.gz
doop.c: (Coverity) found a bug but not quite what Coverity thought it did (try valgrind on the new bop.t without the doop.c patch)
Message-Id: <20060413162046.5F9636D08C@ugli.hut.fi> p4raw-id: //depot/perl@27801
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/doop.c b/doop.c
index 3e6066529a..cfc67cbce8 100644
--- a/doop.c
+++ b/doop.c
@@ -1221,7 +1221,8 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
(void)SvPOK_only(sv);
if (left_utf || right_utf) {
UV duc, luc, ruc;
- char * const dcsave = dc;
+ char *dcorig = dc;
+ char *dcsave = NULL;
STRLEN lulen = leftlen;
STRLEN rulen = rightlen;
STRLEN ulen;
@@ -1239,8 +1240,8 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
dc = (char*)uvchr_to_utf8((U8*)dc, duc);
}
if (sv == left || sv == right)
- (void)sv_usepvn(sv, dcsave, needlen);
- SvCUR_set(sv, dc - dcsave);
+ (void)sv_usepvn(sv, dcorig, needlen);
+ SvCUR_set(sv, dc - dcorig);
break;
case OP_BIT_XOR:
while (lulen && rulen) {
@@ -1266,15 +1267,20 @@ Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
dc = (char*)uvchr_to_utf8((U8*)dc, duc);
}
mop_up_utf:
+ if (rulen)
+ dcsave = savepvn(rc, rulen);
+ else if (lulen)
+ dcsave = savepvn(lc, lulen);
if (sv == left || sv == right)
- (void)sv_usepvn(sv, dcsave, needlen);
- SvCUR_set(sv, dc - dcsave);
+ (void)sv_usepvn(sv, dcorig, needlen); /* Uses Renew(). */
+ SvCUR_set(sv, dc - dcorig);
if (rulen)
- sv_catpvn(sv, rc, rulen);
+ sv_catpvn(sv, dcsave, rulen);
else if (lulen)
- sv_catpvn(sv, lc, lulen);
+ sv_catpvn(sv, dcsave, lulen);
else
*SvEND(sv) = '\0';
+ Safefree(dcsave);
break;
}
SvUTF8_on(sv);