[Gdal-dev] Safety check needed for png read
Frank Warmerdam
warmerdam at pobox.com
Wed Aug 25 09:42:57 EDT 2004
Ben Discoe wrote:
> While in the png code (chasing GDAL crashes) i found that it calls libpng in
> a very unsafe manner, not checking for failure. We really need something
> like this in pngdatset.cpp:
>
> poDS->hPNG = png_create_read_struct(...);
> if (poDS->hPNG == NULL)
> {
> int version = png_access_version_number();
> CPLError( CE_Failure, CPLE_NotSupported,
> "The PNG driver failed to access libpng with version '%s',"
> " library is actually version '%d'.\n",
> PNG_LIBPNG_VER_STRING, version);
> delete poDS;
> return NULL;
> }
>
> This will informatively catch the situation where the libpng libraries and
> headers are out of sync, which is quite easy to get when wrangling with
> library versioning issues, as i have been for the past 5 hours.
Ben,
Suggested change applied.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list