On Thu, Apr 17, 2008 at 11:06:46PM -0400, Tokuhiro Matsuno via RT wrote:
Show quoted text> $img->scale(xpixels => {}) makes segmentation fault.
>
> my machine is: Linux klab-emerson 2.6.8-2-386 #1 Tue Aug 16 12:46:35
> UTC 2005 i686 GNU/Linux
> perl: This is perl, v5.8.4 built for i386-linux-thread-multi
> Imager: 0.63(r1465)
>
> reproducible code is follow:
> >||
> use strict;
> use warnings;
> use Imager;
>
> print "Imager version is: $Imager::VERSION\n";
>
> my $img = Imager->new(xsize => 100, ysize => 100);
> my $scaled = $img->scale(xpixels => {}) or die $img->errstr;
> ||<
Thanks for reporting this.
I've found the cause for this.
The reference parameter was automatically converted to a large integer
by perl, which resulted in an attempt to scale to a very large size.
The low level image creation code (i_img_new_ch()) checked for integer
overflow in calculating the image memory allocation and failed,
returning NULL.
The i_scale_axis() code didn't check for this failure and attempted to
use the NULL pointer.
I've committed the following fix for this:
- i_scale_axis() now checks for the failure, and fails itself by
returning NULL if i_img_new_ch() fails
- the scale_calculate() method, and hence scale() will now fail if any
of the scale size parameters are references.
- this also picked up an error in handling errors from the mixing
scale type, which I've fixed.
Your sample should output:
scale_calculate: xpixels parameter cannot be a reference at foo.pl line 8.
with the changes committed to svn.
I'll do a release fairly soon for this.
Tony