Skip to content

Commit 1ccfe21

Browse files
committed
fix php 72494, invalid color index not handled, can lead to crash
1 parent 3fe0a71 commit 1ccfe21

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Diff for: src/gd_crop.c

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int c
136136
return NULL;
137137
}
138138

139+
if (color < 0 || (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im))) {
140+
return NULL;
141+
}
142+
139143
/* TODO: Add gdImageGetRowPtr and works with ptr at the row level
140144
* for the true color and palette images
141145
* new formats will simply work with ptr

Diff for: tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if (BUILD_TEST)
3131
gdimagecolortransparent
3232
gdimagecopy
3333
gdimagecopyrotated
34+
gdimagecrop
3435
gdimagefile
3536
gdimagefill
3637
gdimagefilledellipse

Diff for: tests/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ include gdimagecolorresolve/Makemodule.am
2525
include gdimagecolortransparent/Makemodule.am
2626
include gdimagecopy/Makemodule.am
2727
include gdimagecopyrotated/Makemodule.am
28+
include gdimagecrop/Makemodule.am
2829
include gdimagefile/Makemodule.am
2930
include gdimagefill/Makemodule.am
3031
include gdimagefilledellipse/Makemodule.am

0 commit comments

Comments
 (0)