Fix two genuine bugs found by Coverity. Checking the wrong pointers for NULL.

This commit is contained in:
Michael Drake 2013-10-23 11:52:37 +01:00
parent 5cddb4ff3c
commit a515248b59

View File

@ -430,7 +430,7 @@ png_cache_convert(struct content *c)
{
png_structp png_ptr;
png_infop info_ptr;
png_infop end_info;
png_infop end_info_ptr;
volatile struct bitmap *bitmap = NULL;
struct png_cache_read_data_s png_cache_read_data;
png_uint_32 width, height;
@ -444,22 +444,20 @@ png_cache_convert(struct content *c)
return NULL;
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL,
nspng_error,
nspng_warning);
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
nspng_error, nspng_warning);
if (png_ptr == NULL) {
return NULL;
}
info_ptr = png_create_info_struct(png_ptr);
if (png_ptr == NULL) {
if (info_ptr == NULL) {
png_destroy_read_struct(&png_ptr, NULL, NULL);
return NULL;
}
end_info = png_create_info_struct(png_ptr);
if (png_ptr == NULL) {
end_info_ptr = png_create_info_struct(png_ptr);
if (end_info_ptr == NULL) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
}
@ -498,7 +496,7 @@ png_cache_convert(struct content *c)
png_cache_convert_error:
/* cleanup png read */
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info_ptr);
free((png_bytep *) row_pointers);