Make Devel::Peek::fill_mstats work on COWs
authorFather Chrysostomos <sprout@cpan.org>
Sun, 5 Jun 2011 02:14:33 +0000 (19:14 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 5 Jun 2011 02:29:04 +0000 (19:29 -0700)
ext/Devel-Peek/Peek.xs
ext/Devel-Peek/t/Peek.t

index 3dcba47..5e8deb9 100644 (file)
@@ -161,6 +161,7 @@ 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);
index 5c6b315..8eedf53 100644 (file)
@@ -770,4 +770,12 @@ do_test('ENAMEs on a stash with no NAME',
     ENAME = "RWOM", "KLANK"                    # $] > 5.012
 ');
 
+SKIP: {
+    skip "Not built with usemymalloc", 1
+      unless $Config{usemymalloc} eq 'y';
+    my $x = __PACKAGE__;
+    ok eval { fill_mstats($x); 1 }, 'fill_mstats on COW scalar'
+     or diag $@;
+}
+
 done_testing();