Opened 14 years ago

Last modified 14 years ago

#1136 closed defect (fixed)

PNGDataset::Open(...) crash when it fails

Reported by: list672000@… Owned by: warmerdam
Priority: high Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description

In PNGDataset::Open(...), if "poDS->hPNG = png_create_read_struct(...)" results 
in poDS->hPNG being NULL, then there is a "delete poDS;" which calls ~PNGDataset
().  In ~PNGDataset(), there is a "png_destroy_read_struct(&hPNG, ...);" which 
seems to crash when hPNG is NULL (using libpng-1.2.8's png_destroy_read_struct
(...)).

It might be crashing on the libpng's png_destroy_read_struct's "free_fn = 
png_ptr->free_fn" line.

Maybe ~PNGDataset() could be changed to check if hPNG is NULL before calling 
png_destroy_read_struct.

Change History (1)

comment:1 Changed 14 years ago by warmerdam

I have modified the code to not png_destroy_read_struct() the 
hPNG if it is NULL.

Let me know if you still see any problems. 

Note: See TracTickets for help on using tickets.