This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #92260] Devel::Peek::fill_mstats and non-PVs
authorFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 23:09:19 +0000 (16:09 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 12 Aug 2013 08:53:27 +0000 (01:53 -0700)
Devel::Peek::fill_mstats assumed that the argument was >= SVt_PV so
it crashed on brand new undef scalars.  Use sv_grow, instead of
SvGROW.  Since sv_grow also handles COWs, we can remove the special
COW check.

ext/Devel-Peek/Peek.xs
ext/Devel-Peek/t/Peek.t

index a8d79f3..4c5f974 100644 (file)
@@ -163,10 +163,9 @@ fill_mstats(SV *sv, int level)
 {
     dTHX;
 
-    if (SvIsCOW(sv)) sv_force_normal(sv);
     if (SvREADONLY(sv))
        croak("Cannot modify a readonly value");
-    SvGROW(sv, sizeof(struct mstats_buffer)+1);
+    sv_grow(sv, sizeof(struct mstats_buffer)+1);
     _fill_mstats((struct mstats_buffer*)SvPVX(sv),level);
     SvCUR_set(sv, sizeof(struct mstats_buffer));
     *SvEND(sv) = '\0';
index 9c01c7f..088f505 100644 (file)
@@ -969,11 +969,13 @@ do_test('large hash',
 ');
 
 SKIP: {
-    skip "Not built with usemymalloc", 1
+    skip "Not built with usemymalloc", 2
       unless $Config{usemymalloc} eq 'y';
     my $x = __PACKAGE__;
     ok eval { fill_mstats($x); 1 }, 'fill_mstats on COW scalar'
      or diag $@;
+    my $y;
+    ok eval { fill_mstats($y); 1 }, 'fill_mstats on undef scalar';
 }
 
 # This is more a test of fbm_compile/pp_study (non) interaction than dumping