undef_int
i_writepng_wiol(i_img *im, io_glue *ig) {
png_structp png_ptr;
- png_infop info_ptr;
+ png_infop info_ptr = NULL;
int width,height,y;
volatile int cspace,channels;
double xres, yres;
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return 0;
}
* error hadnling functions in the png_create_write_struct() call.
*/
if (setjmp(png_ptr->jmpbuf)) {
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
return(0);
}
}
else {
unsigned char *data = mymalloc(im->xsize * im->channels);
- if (data) {
- for (y = 0; y < height; y++) {
- i_gsamp(im, 0, im->xsize, y, data, NULL, im->channels);
- png_write_row(png_ptr, (png_bytep)data);
- }
- myfree(data);
- }
- else {
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
- return 0;
+ for (y = 0; y < height; y++) {
+ i_gsamp(im, 0, im->xsize, y, data, NULL, im->channels);
+ png_write_row(png_ptr, (png_bytep)data);
}
+ myfree(data);
}
png_write_end(png_ptr, info_ptr);
- png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
ig->closecb(ig);
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;