diff options
author | Yitzchak Scott-Thoennes <sthoenna@efn.org> | 2005-11-27 17:26:31 -0800 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-08-09 15:46:55 +0000 |
commit | ced497e2fca8b0ac1628855f422776e9bf331e65 (patch) | |
tree | 8c9862d08cb942d5ab79b75cdd14bfab9ecdeb87 /sv.c | |
parent | e6f8b432a6859b2fcff710fa0ce40a8c0f93bf2b (diff) | |
download | perl-ced497e2fca8b0ac1628855f422776e9bf331e65.tar.gz |
Re: [perl #37731] junk and uninit'ed values in tied scalars
Message-ID: <20051128092605.GA2328@efn.org>
plus a regression test
p4raw-id: //depot/perl@28684
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -5928,8 +5928,16 @@ Perl_sv_eq(pTHX_ register SV *sv1, register SV *sv2) pv1 = ""; cur1 = 0; } - else + else { + /* if pv1 and pv2 are the same, second SvPV_const call may + * invalidate pv1, so we may need to make a copy */ + if (sv1 == sv2 && (SvTHINKFIRST(sv1) || SvGMAGICAL(sv1))) { + pv1 = SvPV_const(sv1, cur1); + sv1 = sv_2mortal(newSVpvn(pv1, cur1)); + if (SvUTF8(sv2)) SvUTF8_on(sv1); + } pv1 = SvPV_const(sv1, cur1); + } if (!sv2){ pv2 = ""; |