Subject: | Another divide-by-zero bug |
Date: | Fri, 22 Sep 2006 01:04:27 -0700 |
To: | bug-GDGraph [...] rt.cpan.org |
From: | Phil Dibowitz <phil [...] ipom.com> |
Message body not shown because it is not plain text.
I get a divide-by-zero bug when using GD::Graph like so:
Illegal division by zero at
/usr/lib/perl5/site_perl/5.8.0/GD/Graph/axestype.pm line 1905.
This seems to be different than all the other ones currently in RT.
I've attached a patch for the issue.
Here's the relevant version info:
perl: 5.8.0-94.EL3
perl-GD: 1.41
perl-GD-Graph: 1.4308
perl-GD-Text: 0.86
gd: 1.8.4-12.3.1
kernel: 2.4.21-47.ELsmp
Red Hat Enterprise Linux AS release 3 (Taroon Update 8)
--
Phil Dibowitz phil@ipom.com
Freeware and Technical Pages Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/
"Be who you are and say what you feel, because those who mind don't matter
and those who matter don't mind."
- Dr. Seuss
--- axestype.pm.bk.phil 2006-09-22 00:37:48.000000000 -0700
+++ axestype.pm 2006-09-22 00:58:14.000000000 -0700
@@ -1902,9 +1902,12 @@
my $y_min = $self->{y_min}[$axis];
my $y_max = $self->{y_max}[$axis];
+ my $y_diff = $y_max - $y_min;
+ $y_diff = 1 if ($y_diff == 0);
+
my $y_step = $self->{rotate_chart} ?
- abs(($self->{right} - $self->{left})/($y_max - $y_min)) :
- abs(($self->{bottom} - $self->{top})/($y_max - $y_min));
+ abs(($self->{right} - $self->{left})/$y_diff) :
+ abs(($self->{bottom} - $self->{top})/$y_diff);
my $ret_x;
my $origin = $self->{rotate_chart} ? $self->{top} : $self->{left};