From: Vincent Pit Date: Fri, 29 Jul 2016 15:42:46 +0000 (-0300) Subject: Only allow 24 callers X-Git-Tag: v1.19~7 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Valgrind.git;a=commitdiff_plain;h=d77165d74a0a4d3a18143cd63cdb624252058698 Only allow 24 callers valgrind doesn't allow more anyway. --- diff --git a/lib/Test/Valgrind.pm b/lib/Test/Valgrind.pm index 421396f..1df876c 100644 --- a/lib/Test/Valgrind.pm +++ b/lib/Test/Valgrind.pm @@ -96,7 +96,7 @@ C<< callers => $number >> Specify the maximum stack depth studied when valgrind encounters an error. Raising this number improves granularity. -Ignored if you supply your own custom C, otherwise defaults to C<50>. +Ignored if you supply your own custom C, otherwise defaults to C<24> (the maximum allowed by C). =item * @@ -209,12 +209,14 @@ sub analyse { my $tool = delete $args{tool}; unless ($tool->$instanceof('Test::Valgrind::Tool')) { + my $callers = delete $args{callers} || 24; + $callers = 24 if $callers <= 0; require Test::Valgrind::Tool; local $@; $tool = eval { Test::Valgrind::Tool->new( - tool => $tool || 'memcheck', - callers => delete $args{callers}, + tool => $tool || 'memcheck', + callers => $callers, ); }; unless ($tool) { diff --git a/lib/Test/Valgrind/Tool/memcheck.pm b/lib/Test/Valgrind/Tool/memcheck.pm index 9064b5d..b300f66 100644 --- a/lib/Test/Valgrind/Tool/memcheck.pm +++ b/lib/Test/Valgrind/Tool/memcheck.pm @@ -21,6 +21,8 @@ This class contains the information required by the session for running the C; =head1 METHODS @@ -58,8 +60,11 @@ sub new { my %args = @_; - my $callers = delete $args{callers} || 50; - $callers =~ s/\D//g; + my $callers = delete $args{callers}; + $callers = 24 unless $callers; + die 'Invalid number of callers' + unless Scalar::Util::looks_like_number($callers) and $callers > 0 + and $callers <= 24; my $self = bless $class->Test::Valgrind::Tool::new(%args), $class; @@ -68,7 +73,7 @@ sub new { $self; } -sub new_trainer { shift->new(callers => 50) } +sub new_trainer { shift->new(callers => 24) } =head2 C