Change 32778 by [EMAIL PROTECTED] on 2007/12/29 19:50:27

        In sv_chop(), write sentinals over the part of the buffer that is
        thrown away, and verify that they are present in sv_backoff().
        assert that we are being asked to chop off positive amounts of buffer.

Affected files ...

... //depot/perl/sv.c#1460 edit

Differences ...

==== //depot/perl/sv.c#1460 (text) ====
Index: perl/sv.c
--- perl/sv.c#1459~32777~       2007-12-29 11:32:52.000000000 -0800
+++ perl/sv.c   2007-12-29 11:50:27.000000000 -0800
@@ -1403,6 +1403,16 @@
     assert(SvTYPE(sv) != SVt_PVAV);
     if (SvIVX(sv)) {
        const char * const s = SvPVX_const(sv);
+#ifdef DEBUGGING
+       /* Validate the preceding buffer's sentinals to verify that no-one is
+          using it.  */
+       const U8 *p = (const U8*) s;
+       const U8 *const real_start = p - SvIVX(sv);
+       while (p > real_start) {
+           --p;
+           assert (*p == (U8)PTR2UV(p));
+       }
+#endif
        SvLEN_set(sv, SvLEN(sv) + SvIVX(sv));
        SvPV_set(sv, SvPVX(sv) - SvIVX(sv));
        SvIV_set(sv, 0);
@@ -4215,6 +4225,7 @@
        /* Nothing to do.  */
        return;
     }
+    assert(ptr > SvPVX_const(sv));
     SV_CHECK_THINKFIRST(sv);
     if (SvTYPE(sv) < SVt_PVIV)
        sv_upgrade(sv,SVt_PVIV);
@@ -4238,6 +4249,18 @@
     SvCUR_set(sv, SvCUR(sv) - delta);
     SvPV_set(sv, SvPVX(sv) + delta);
     SvIV_set(sv, SvIVX(sv) + delta);
+#ifdef DEBUGGING
+    {
+       /* Fill the preceding buffer with sentinals to verify that no-one is
+          using it.  */
+       U8 *p = (U8*) SvPVX(sv);
+       const U8 *const real_start = p - SvIVX(sv);
+       while (p > real_start) {
+           --p;
+           *p = (U8)PTR2UV(p);
+       }
+    }
+#endif
 }
 
 /*
End of Patch.

Reply via email to