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

master
Pierre Joye 2016-06-04 23:09:01 +07:00
parent 73f4e0339a
commit 77f619d482
4 changed files with 11 additions and 2 deletions

View File

@ -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;

View File

@ -1 +1,2 @@
/bug00037
/github_bug_215

View File

@ -1,5 +1,6 @@
SET(TESTS_FILES
bug00037
github_bug_215
)
ADD_GD_TESTS()

View File

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