Skip Menu |
 

This queue is for tickets about the GDGraph-boxplot CPAN distribution.

Report information
The Basics
Id: 45075
Status: new
Priority: 0/
Queue: GDGraph-boxplot

People
Owner: Nobody in particular
Requestors: rajas [...] andrew.cmu.edu
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.00
Fixed in: (no value)



Subject: uninitialized loop control variable when computing stats from raw values (do_stats ==1)
Download (untitled) / with headers
text/plain 1.4k
When raw values are input to boxplot.pm (i.e., do_stats is set to 1), the code loops through the input raw values a few times to find the max,min, and other values necessary to draw the boxplots. However, the control variable used in each of these loops is never initialized to a starting value, thus causing perl to return an error when one tries to call boxplot.pm. Additonally, during the first iteration of these loops, the code tries to compare the raw_value[0] to $min or $max, which are undefined. If the user inputs pre-computed values for the boxplot (i.e. sets do_stats to 0), these for loops are never executed and there is no error. I have attached a patch that fixes this bug. Perl version: 5.8.8 GDGraph-Boxplot-1.00 Operating system: Linux 2.6.18 This problem can be reproduced by simply following the example stated in the CPAN overview page: $one = [210..275]; $two = [180, 190, 200, 220, 235, 245]; $three = [40, 140..150, 160..180, 250]; $four = [100..125, 136..140]; $five = [10..50, 100, 180]; @data = ( ["1st", "2nd", "3rd", "4th", "5th"], [$one, $two, $three, $four, $five ], [ [-25, 1..15], [-45, 25..45, 100], [70, 42..125], [undef], [180..250] ], # as many sets of data sets as you like ); $my_graph = new GD::Graph::boxplot( ); $gd = $my_graph->plot( \@data );
Subject: boxplot_patch.patch
Download boxplot_patch.patch
text/x-diff 1.5k
--- /h/rajas/usr/src/GDGraph-boxplot-1.00/boxplot.pm 2001-07-07 12:47:06.000000000 -0400 +++ /h/rajas/usr/lib/perl5/site_perl/5.8.8/GD/Graph/boxplot.pm 2009-04-08 03:25:45.598110000 -0400 @@ -320,7 +320,7 @@ sub draw_data_set # first check all the values above the box if ($stat->max() > $maxim) { - for(my $j; defined $value->[$j]; $j++) + for(my $j = 0; defined $value->[$j]; $j++) { if ($value->[$j] > $maxim) { @@ -362,7 +362,7 @@ sub draw_data_set # now repeat the same procedure for values below the box if ($stat->min() < $minim) { - for (my $j; defined $value->[$j]; $j++) + for (my $j = 0; defined $value->[$j]; $j++) { if ($value->[$j] < $minim) { @@ -460,19 +460,19 @@ sub set_max_min my $max = undef; my $min = undef; - + if( $self->{do_stats} ) { for my $i ( 1 .. $self->{_data}->num_sets ) # 1 because x-labels are [0] { for my $j ( 0 .. $self->{_data}->num_points ) { - for (my $k; defined $self->{_data}->[$i][$j][$k]; $k++ ) + for (my $k = 0; defined $self->{_data}->[$i][$j][$k]; $k++ ) { $max = $self->{_data}->[$i][$j][$k] - if ($self->{_data}->[$i][$j][$k] > $max); + if (!defined $max || $self->{_data}->[$i][$j][$k] > $max); $min = $self->{_data}->[$i][$j][$k] - if ($self->{_data}->[$i][$j][$k] < $min); + if (!defined $min || $self->{_data}->[$i][$j][$k] < $min); } } }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.