jpeg, bmp or tga files.
We now expand the palette to match the indexes used.
Thanks to Gabriel Vasseur for reporting this.
+ - fixed various memory leaks that could occur when failing to read png,
+ jpeg, bmp or tga files.
+
Imager 0.59 - 14 June 2007
===========
else if (packed[0]) {
if (x + packed[0] > xsize) {
/* this file is corrupt */
+ myfree(packed);
myfree(line);
i_push_error(0, "invalid data during decompression");
i_img_destroy(im);
count = packed[1];
if (x + count > xsize) {
/* this file is corrupt */
+ myfree(packed);
myfree(line);
i_push_error(0, "invalid data during decompression");
i_img_destroy(im);
entry->item_size = type_sizes[entry->type];
entry->size = entry->item_size * entry->count;
if (entry->size / entry->item_size != entry->count) {
+ myfree(entries);
mm_log((1, "Integer overflow calculating tag data size processing EXIF block\n"));
return 0;
}
*/
i_img*
i_readjpeg_wiol(io_glue *data, int length, char** iptc_itext, int *itlength) {
- i_img *im;
+ i_img * volatile im = NULL;
#ifdef IMEXIF_ENABLE
int seen_exif = 0;
#endif
jpeg_saved_marker_ptr markerp;
transfer_function_t transfer_f;
int channels;
+ volatile int src_set = 0;
mm_log((1,"i_readjpeg_wiol(data 0x%p, length %d,iptc_itext 0x%p)\n", data, length, iptc_itext));
/* Set error handler */
if (setjmp(jerr.setjmp_buffer)) {
+ if (src_set)
+ wiol_term_source(&cinfo);
jpeg_destroy_decompress(&cinfo);
*iptc_itext=NULL;
*itlength=0;
if (line_buffer)
myfree(line_buffer);
+ if (im)
+ i_img_destroy(im);
return NULL;
}
jpeg_save_markers(&cinfo, JPEG_APP1, 0xFFFF);
jpeg_save_markers(&cinfo, JPEG_COM, 0xFFFF);
jpeg_wiol_src(&cinfo, data, length);
+ src_set = 1;
(void) jpeg_read_header(&cinfo, TRUE);
(void) jpeg_start_decompress(&cinfo);
i_img*
i_readpng_wiol(io_glue *ig, int length) {
- i_img *im;
+ i_img *im = NULL;
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 width, height;
}
if (setjmp(png_ptr->jmpbuf)) {
+ if (im) i_img_destroy(im);
mm_log((1,"i_readpng_wiol: error.\n"));
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
return NULL;
for(y=0; y<height; y++) {
if (!tga_source_read(&src, databuf, width)) {
i_push_error(errno, "read for targa data failed");
+ if (linebuf) myfree(linebuf);
myfree(databuf);
if (img) i_img_destroy(img);
return NULL;