Skip to content

Commit

Permalink
fix #215 gdImageFillToBorder stack-overflow when invalid color is used
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejoye committed Jun 4, 2016
1 parent 73f4e03 commit 77f619d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/gd.c
Expand Up @@ -1928,11 +1928,17 @@ BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
int i; int i;
int restoreAlphaBleding; int restoreAlphaBleding;


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


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

leftLimit = (-1); leftLimit = (-1);


restoreAlphaBleding = im->alphaBlendingFlag; restoreAlphaBleding = im->alphaBlendingFlag;
Expand Down
1 change: 1 addition & 0 deletions tests/gdimagefilltoborder/.gitignore
@@ -1 +1,2 @@
/bug00037 /bug00037
/github_bug_215
1 change: 1 addition & 0 deletions tests/gdimagefilltoborder/CMakeLists.txt
@@ -1,5 +1,6 @@
SET(TESTS_FILES SET(TESTS_FILES
bug00037 bug00037
github_bug_215
) )


ADD_GD_TESTS() ADD_GD_TESTS()
3 changes: 2 additions & 1 deletion tests/gdimagefilltoborder/Makemodule.am
@@ -1,6 +1,7 @@
if HAVE_LIBPNG if HAVE_LIBPNG
libgd_test_programs += \ libgd_test_programs += \
gdimagefilltoborder/bug00037 gdimagefilltoborder/bug00037 \
gdimagefilltoborder/github_bug_215
endif endif


EXTRA_DIST += \ EXTRA_DIST += \
Expand Down

0 comments on commit 77f619d

Please sign in to comment.