]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/commitdiff
Only allow 24 callers
authorVincent Pit <perl@profvince.com>
Fri, 29 Jul 2016 15:42:46 +0000 (12:42 -0300)
committerVincent Pit <perl@profvince.com>
Fri, 29 Jul 2016 15:42:46 +0000 (12:42 -0300)
valgrind doesn't allow more anyway.

lib/Test/Valgrind.pm
lib/Test/Valgrind/Tool/memcheck.pm

index 421396f90f71644edc6527debde133ffb3d6f7a0..1df876c3d10fb8f91d8d28d75e21a84ba5fe37a5 100644 (file)
@@ -96,7 +96,7 @@ C<< callers => $number >>
 Specify the maximum stack depth studied when valgrind encounters an error.
 Raising this number improves granularity.
 
 Specify the maximum stack depth studied when valgrind encounters an error.
 Raising this number improves granularity.
 
-Ignored if you supply your own custom C<tool>, otherwise defaults to C<50>.
+Ignored if you supply your own custom C<tool>, otherwise defaults to C<24> (the maximum allowed by C<valgrind>).
 
 =item *
 
 
 =item *
 
@@ -209,12 +209,14 @@ sub analyse {
 
  my $tool = delete $args{tool};
  unless ($tool->$instanceof('Test::Valgrind::Tool')) {
 
  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(
   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) {
    );
   };
   unless ($tool) {
index 9064b5d90e6e25d5fa695f368e8a003f307ce9a2..b300f66da1319a624ee7b171ec1506d76471ca90 100644 (file)
@@ -21,6 +21,8 @@ This class contains the information required by the session for running the C<me
 
 =cut
 
 
 =cut
 
+use Scalar::Util ();
+
 use base qw<Test::Valgrind::Tool>;
 
 =head1 METHODS
 use base qw<Test::Valgrind::Tool>;
 
 =head1 METHODS
@@ -58,8 +60,11 @@ sub new {
 
  my %args = @_;
 
 
  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;
 
 
  my $self = bless $class->Test::Valgrind::Tool::new(%args), $class;
 
@@ -68,7 +73,7 @@ sub new {
  $self;
 }
 
  $self;
 }
 
-sub new_trainer { shift->new(callers => 50) }
+sub new_trainer { shift->new(callers => 24) }
 
 =head2 C<callers>
 
 
 =head2 C<callers>