diff --git a/src/gd_crop.c b/src/gd_crop.c index 02966336d..532b49b3b 100644 --- a/src/gd_crop.c +++ b/src/gd_crop.c @@ -136,6 +136,10 @@ BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int c return NULL; } + if (color < 0 || (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im))) { + return NULL; + } + /* TODO: Add gdImageGetRowPtr and works with ptr at the row level * for the true color and palette images * new formats will simply work with ptr diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6f5c78604..5093d526a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,6 +31,7 @@ if (BUILD_TEST) gdimagecolortransparent gdimagecopy gdimagecopyrotated + gdimagecrop gdimagefile gdimagefill gdimagefilledellipse diff --git a/tests/Makefile.am b/tests/Makefile.am index 4f6e75699..5a0ebe81e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,6 +25,7 @@ include gdimagecolorresolve/Makemodule.am include gdimagecolortransparent/Makemodule.am include gdimagecopy/Makemodule.am include gdimagecopyrotated/Makemodule.am +include gdimagecrop/Makemodule.am include gdimagefile/Makemodule.am include gdimagefill/Makemodule.am include gdimagefilledellipse/Makemodule.am