In Perl_sv_usepvn(), force a move under DEBUGGING to shake out caller
Nicholas Clark [Sun, 16 Apr 2006 10:37:46 +0000 (10:37 +0000)]
bugs.

p4raw-id: //depot/perl@27839

sv.c

diff --git a/sv.c b/sv.c
index 8171c7f..3c8fa77 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3915,7 +3915,18 @@ Perl_sv_usepvn(pTHX_ register SV *sv, register char *ptr, register STRLEN len)
        SvPV_free(sv);
 
     allocate = PERL_STRLEN_ROUNDUP(len + 1);
+#ifdef DEBUGGING
+    {
+       /* Force a move to shake out bugs in callers.  */
+       char *new_ptr = safemalloc(allocate);
+       Copy(ptr, new_ptr, len, char);
+       PoisonFree(ptr,len,char);
+       Safefree(ptr);
+       ptr = new_ptr;
+    }
+#else
     ptr = saferealloc (ptr, allocate);
+#endif
     SvPV_set(sv, ptr);
     SvCUR_set(sv, len);
     SvLEN_set(sv, allocate);