Skip to content
Permalink
Browse files

fix #215 gdImageFillToBorder stack-overflow when invalid color is used

  • Loading branch information...
pierrejoye committed Jun 4, 2016
1 parent 73f4e03 commit 77f619d48259383628c3ec4654b1ad578e9eb40e
@@ -1928,11 +1928,17 @@ BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
int i;
int restoreAlphaBleding;

if (border < 0) {
if (border < 0 || color < 0) {
/* Refuse to fill to a non-solid border */
return;
}

if (!im->trueColor) {
if ((color > (im->colorsTotal - 1)) || (border > (im->colorsTotal - 1))) {
return;
}
}

leftLimit = (-1);

restoreAlphaBleding = im->alphaBlendingFlag;
@@ -1 +1,2 @@
/bug00037
/github_bug_215
@@ -1,5 +1,6 @@
SET(TESTS_FILES
bug00037
github_bug_215
)

ADD_GD_TESTS()
@@ -1,6 +1,7 @@
if HAVE_LIBPNG
libgd_test_programs += \
gdimagefilltoborder/bug00037
gdimagefilltoborder/bug00037 \
gdimagefilltoborder/github_bug_215
endif

EXTRA_DIST += \

0 comments on commit 77f619d

Please sign in to comment.
You can’t perform that action at this time.