Skip to content
This repository

throw instead of abort on invalid PNG images #1213

Closed
springmeyer opened this Issue · 0 comments

2 participants

Dane Springmeyer Artem Pavlenko
Dane Springmeyer
Owner

Some of the corrupt images from http://www.schaik.com/pngsuite/ trigger aborts. We should avoid this.

~/Downloads/PngSuite-2011apr25$ for i in $(ls *png); do python -c "import mapnik;mapnik.Image.open('$i')";done
libpng warning: Invalid color type in IHDR
libpng error: Invalid IHDR data
Abort trap: 6
libpng warning: Invalid color type in IHDR
libpng error: Invalid IHDR data
Abort trap: 6
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: xcrn0g04.png is not a png file
libpng error: IDAT: CRC error
Abort trap: 6
libpng warning: Invalid bit depth in IHDR
libpng warning: Invalid color type/bit depth combination in IHDR
libpng error: Invalid IHDR data
Abort trap: 6
libpng warning: Invalid bit depth in IHDR
libpng warning: Invalid color type/bit depth combination in IHDR
libpng error: Invalid IHDR data
Abort trap: 6
libpng warning: Invalid bit depth in IHDR
libpng error: Invalid IHDR data
Abort trap: 6
libpng error: No image in file
Abort trap: 6
libpng error: IHDR: CRC error
Abort trap: 6
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: xlfn0g04.png is not a png file
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: xs1n0g01.png is not a png file
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: xs2n0g01.png is not a png file
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: xs4n0g01.png is not a png file
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: xs7n0g01.png is not a png file
Artem Pavlenko artemp closed this issue from a commit
Catch and throw PNG exceptions - fixes #1213
The png library uses setjmp/longjmp to throw exceptions when reading. If this
is not set up, the png library calls abort(). This change handles the errors
and throws a C++ exception instead.

This issue was found by testing images from pngsuite at
http://www.schaik.com/pngsuite/. These images are included and a unit test was
added to test both images that should be successful and images that should
throw an exception.
cd7ad3e
Artem Pavlenko artemp closed this in cd7ad3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.