Imager release history. Older releases can be found in Changes.old
+Coverity finally finished a build, fix a few problems:
+
+ - reading a color-mapped TGA file with an id string would cause a
+ double-free if the palette was truncated.
+
Imager 1.008 - 31 Dec 2018
============
#!perl -w
use Imager qw(:all);
use strict;
-use Test::More tests=>68;
+use Test::More;
use Imager::Test qw(is_color4 is_image test_image);
-d "testout" or mkdir "testout";
}
}
+{
+ # coverity issue - double free of idstring
+ my $im = test_image()->to_paletted({ make_colors => "webmap" });
+ my $data;
+ ok($im->write(data => \$data, type => "tga", idstring => "test"),
+ "save good tga image");
+ substr($data, 30) = '';
+ my $im2 = Imager->new;
+ ok(!$im2->read(data => \$data, type => "tga"),
+ "fail to read bad tga");
+ like($im2->errstr, qr/could not read targa colormap/,
+ "check error message");
+ # shouldn't get a double free from valgrind
+}
+
{ # check close failures are handled correctly
my $im = test_image();
my $fail_close = sub {
"check error message");
}
+done_testing();
+
sub write_test {
my ($im, $filename, $wierdpack, $compress, $idstring) = @_;
local *FH;
palbuf = mymalloc(palbsize);
if (i_io_read(ig, palbuf, palbsize) != palbsize) {
- i_push_error(errno, "could not read targa colourmap");
+ i_push_error(errno, "could not read targa colormap");
return 0;
}
}
if (i_io_write(ig, palbuf, palbsize) != palbsize) {
- i_push_error(errno, "could not write targa colourmap");
+ i_push_error(errno, "could not write targa colormap");
return 0;
}
myfree(palbuf);
bpp_to_bytes(header.colourmapdepth),
header.colourmaplength)
) {
- i_push_error(0, "Targa Image has none of 15/16/24/32 pixel layout");
- if (idstring) myfree(idstring);
+ /* tga_palette_read() sets a message */
if (img) i_img_destroy(img);
return NULL;
}