summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorAdrian M. Enache <enache@rdslink.ro>2003-05-30 21:52:28 +0300
committerJarkko Hietaniemi <jhi@iki.fi>2003-05-31 05:37:10 +0000
commit31869a7926d2c97f2a8de68f2374ea5aa42dd78f (patch)
treec4173b5cb57cd96f68e3456e3057b860c2afa6ba /sv.c
parent91707c8168970b176176e6ddb3c00060363fecc1 (diff)
downloadperl-31869a7926d2c97f2a8de68f2374ea5aa42dd78f.tar.gz
Re: [perl #22372] [PATCH] sv_chop() broken
Message-ID: <20030530155228.GA872@ratsnest.hole> p4raw-id: //depot/perl@19645
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sv.c b/sv.c
index 310ba50465..d6ae16c7d8 100644
--- a/sv.c
+++ b/sv.c
@@ -4501,6 +4501,8 @@ Efficient removal of characters from the beginning of the string buffer.
SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside
the string buffer. The C<ptr> becomes the first character of the adjusted
string. Uses the "OOK hack".
+Beware: after this function returns, C<ptr> and SvPVX(sv) may no longer
+refer to the same chunk of data.
=cut
*/
@@ -4509,9 +4511,9 @@ void
Perl_sv_chop(pTHX_ register SV *sv, register char *ptr)
{
register STRLEN delta;
-
if (!ptr || !SvPOKp(sv))
return;
+ delta = ptr - SvPVX(sv);
SV_CHECK_THINKFIRST(sv);
if (SvTYPE(sv) < SVt_PVIV)
sv_upgrade(sv,SVt_PVIV);
@@ -4531,7 +4533,6 @@ Perl_sv_chop(pTHX_ register SV *sv, register char *ptr)
SvFLAGS(sv) |= SVf_OOK;
}
SvNIOK_off(sv);
- delta = ptr - SvPVX(sv);
SvLEN(sv) -= delta;
SvCUR(sv) -= delta;
SvPVX(sv) += delta;