This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Devel::PPPort: force string when testing SvPV_renew
authorFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 18:15:27 +0000 (11:15 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 12 Aug 2013 08:53:25 +0000 (01:53 -0700)
Otherwise we could be reallocating a buffer shared by another scalar.

cpan/Devel-PPPort/parts/inc/SvPV
cpan/Devel-PPPort/t/SvPV.t

index a7aace7..4894c3c 100644 (file)
@@ -510,6 +510,7 @@ $mhx = 42; ok(&Devel::PPPort::SvPV_nomg_const($mhx), 2);
 $mhx = 42; ok(&Devel::PPPort::SvPV_nomg_const_nolen($mhx), 0);
 
 my $str = "";
+&Devel::PPPort::SvPV_force($str);
 my($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 81, "x"x80);
 ok($str, "x"x80);
 ok($s2, "x"x80);
@@ -517,6 +518,7 @@ ok($before < 81);
 ok($after, 81);
 
 $str = "x"x400;
+&Devel::PPPort::SvPV_force($str);
 ($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 41, "x"x40);
 ok($str, "x"x40);
 ok($s2, "x"x40);
index 63c7d72..025c461 100644 (file)
@@ -101,6 +101,7 @@ $mhx = 42; ok(&Devel::PPPort::SvPV_nomg_const($mhx), 2);
 $mhx = 42; ok(&Devel::PPPort::SvPV_nomg_const_nolen($mhx), 0);
 
 my $str = "";
+&Devel::PPPort::SvPV_force($str);
 my($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 81, "x"x80);
 ok($str, "x"x80);
 ok($s2, "x"x80);
@@ -108,6 +109,7 @@ ok($before < 81);
 ok($after, 81);
 
 $str = "x"x400;
+&Devel::PPPort::SvPV_force($str);
 ($s2, $before, $after) = &Devel::PPPort::SvPV_renew($str, 41, "x"x40);
 ok($str, "x"x40);
 ok($s2, "x"x40);