fix a TGA ping crash

see https://github.com/jcupitt/libvips/issues/980
This commit is contained in:
John Cupitt 2018-05-25 16:40:50 +01:00
parent 5b132ccbdc
commit 4058312aee
3 changed files with 25 additions and 0 deletions

View File

@ -3,6 +3,7 @@
- revise C++ example [fangqiao]
- strict round down on jpeg shrink on load [davidwood]
- configure test for g++ 7.2 and composite.cpp
- fix a crash with TGA ping [jtorresfabra]
12/2/18 started 8.6.3
- use pkg-config to find libjpeg, if we can

View File

@ -662,6 +662,17 @@ if test x"$magick6" = x"yes"; then
LIBS="$save_LIBS"
fi
if test x"$magick6" = x"yes"; then
# more recent magick6s have AcquireImageColormap rather than
# AllocateImageColormap groan
save_LIBS="$LIBS"
LIBS="$LIBS $MAGICK_LIBS"
AC_CHECK_FUNCS(AcquireImageColormap,
AC_DEFINE(HAVE_ACQUIREIMAGECOLORMAP,1,
[define if your magick has AcquireImageColormap.]))
LIBS="$save_LIBS"
fi
if test x"$magick6" = x"yes"; then
# more recent magicks have GetVirtualPixels rather than GetImagePixels
save_LIBS="$LIBS"

View File

@ -335,6 +335,19 @@ parse_header( Read *read )
if( (im->Bands = get_bands( image )) < 0 )
return( -1 );
/* Some ImageMagick loaders (eg. TGA) fail to set the ->colormap
* field on Ping. GetImageChannelDepth() needs this and
* will crash if it's not set.
*
* If there's no colormap, set an empty one.
*/
if( !image->colormap )
#ifdef HAVE_ACQUIREIMAGECOLORMAP
AcquireImageColormap( image, image->colors );
#else /*!HAVE_ACQUIREIMAGECOLORMAP*/
AllocateImageColormap( image, image->colors );
#endif /*HAVE_ACQUIREIMAGECOLORMAP*/
/* Depth can be 'fractional'.
*
* You'd think we should use