From 80b6a949dbabd822cf5e1cf2ece76164d772f0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 11 Sep 2010 09:58:02 +0000 Subject: segfault on &Internals::* due to missing SvROK() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the &Internals::* functions that use references in their prototypes to check if the argument is SvROK() before calling SvRV(). If the function is called as Internals::FOO() perl does this check for us, but prototypes are bypassed on &Internals::FOO() so we still have to check this manually. This fixes [perl #77776], this bug was present in 5.10.x, 5.12.x, and probably all earlier perl versions that had these functions, but I haven't tested that. I'm adding a new test file (t/lib/universal.t) to test universal.c functions as part of this patch. The testing for Internal::* in t/ was and is very sparse, but before universal.t there was no obvious place to put these tests. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/lib/universal.t | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 t/lib/universal.t (limited to 't/lib') diff --git a/t/lib/universal.t b/t/lib/universal.t new file mode 100644 index 0000000000..d8c088920b --- /dev/null +++ b/t/lib/universal.t @@ -0,0 +1,25 @@ +#!./perl + +# Test the Internal::* functions and other tibits in universal.c + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; + plan( tests => 4 ); +} + +for my $arg ('', 'q[]', qw( 1 undef )) { + fresh_perl_is(<<"----", <<'====', "Internals::* functions check their argument under func() AND &func() [perl #77776]"); +sub tryit { eval shift or warn \$@ } +tryit "&Internals::SvREADONLY($arg)"; +tryit "&Internals::SvREFCNT($arg)"; +tryit "&Internals::hv_clear_placeholders($arg)"; +tryit "&Internals::HvREHASH($arg)"; +---- +Usage: Internals::SvREADONLY(SCALAR[, ON]) at (eval 1) line 1. +Usage: Internals::SvREFCNT(SCALAR[, REFCOUNT]) at (eval 2) line 1. +Usage: Internals::hv_clear_placeholders(hv) at (eval 3) line 1. +Internals::HvREHASH $hashref at (eval 4) line 1. +==== +} -- cgit v1.2.1