This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
assert() that the pointer passed to Perl_sv_chop() lies within the
authorNicholas Clark <nick@ccl4.org>
Sun, 13 Jul 2008 04:04:31 +0000 (04:04 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 13 Jul 2008 04:04:31 +0000 (04:04 +0000)
buffer of the SV.

p4raw-id: //depot/perl@34136

sv.c

diff --git a/sv.c b/sv.c
index 6ac3408..cdae779 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -4401,6 +4401,10 @@ Perl_sv_chop(pTHX_ register SV *const sv, register const char *const ptr)
     }
     assert(ptr > SvPVX_const(sv));
     SV_CHECK_THINKFIRST(sv);
     }
     assert(ptr > SvPVX_const(sv));
     SV_CHECK_THINKFIRST(sv);
+    if (SvLEN(sv))
+       assert(delta <= SvLEN(sv));
+    else
+       assert(delta <= SvCUR(sv));
 
     if (!SvOOK(sv)) {
        if (!SvLEN(sv)) { /* make copy of shared string */
 
     if (!SvOOK(sv)) {
        if (!SvLEN(sv)) { /* make copy of shared string */