Skip to content

Commit

Permalink
fix php 72494, invalid color index not handled, can lead to crash
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejoye committed Jun 27, 2016
1 parent 3fe0a71 commit 1ccfe21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/gd_crop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if (BUILD_TEST)
gdimagecolortransparent
gdimagecopy
gdimagecopyrotated
gdimagecrop
gdimagefile
gdimagefill
gdimagefilledellipse
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ccfe21

Please sign in to comment.