summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/tests
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2017-01-18 23:13:46 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2017-01-18 23:13:46 +0000
commit1f3a1e3f83772c4ccc91a723000fb2374014a4d2 (patch)
treeb165bf15729fa287a73aaa13fb97333d3cafef85 /Build/source/libs/gd/libgd-src/tests
parentbe747857c72b720d2b81baead7c10f043e8a2588 (diff)
libgd 2.2.4
git-svn-id: svn://tug.org/texlive/trunk@42987 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/tests')
-rw-r--r--Build/source/libs/gd/libgd-src/tests/CMakeLists.txt10
-rw-r--r--Build/source/libs/gd/libgd-src/tests/Makefile.am13
-rw-r--r--Build/source/libs/gd/libgd-src/tests/bmp/CMakeLists.txt2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/bmp/Makemodule.am4
-rw-r--r--Build/source/libs/gd/libgd-src/tests/bmp/bug00275.c53
-rw-r--r--Build/source/libs/gd/libgd-src/tests/bmp/bug00276.c32
-rw-r--r--Build/source/libs/gd/libgd-src/tests/fontconfig/CMakeLists.txt7
-rw-r--r--Build/source/libs/gd/libgd-src/tests/fontconfig/Makemodule.am9
-rw-r--r--Build/source/libs/gd/libgd-src/tests/fontconfig/basic.c33
-rw-r--r--Build/source/libs/gd/libgd-src/tests/freetype/CMakeLists.txt2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/freetype/bug00132.c1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/CMakeLists.txt4
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/Makemodule.am10
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/bug00309.c37
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/bug00354.c32
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/bug00354a.gd2bin0 -> 92 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/bug00354b.gd2bin0 -> 18 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/bug_289.c33
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339.c31
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339_exp.gd2bin67108882 -> 0 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.c22
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.gd2bin0 -> 1050 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagebrightness/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagebrightness/Makemodule.am10
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic+100.pngbin0 -> 2028 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic-100.pngbin0 -> 2004 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.c41
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.pngbin0 -> 2009 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageclone/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageclone/Makemodule.am5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageclone/bug00300.c32
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecolor/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecolor/Makemodule.am9
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.c29
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.pngbin0 -> 2092 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic_exp.pngbin0 -> 2140 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecontrast/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecontrast/Makemodule.am10
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic+50.pngbin0 -> 2024 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic-50.pngbin0 -> 2034 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.c41
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.pngbin0 -> 2009 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/Makemodule.am12
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.c62
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.pngbin0 -> 49446 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_edge_detect_quick.pngbin0 -> 42824 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_emboss.pngbin0 -> 36783 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_mean_removal.pngbin0 -> 45395 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_smooth.pngbin0 -> 24595 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecopyrotated/bug00020.c5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecreate/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecreate/Makemodule.am5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecreate/bug00340.c33
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecrop/CMakeLists.txt1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecrop/Makemodule.am1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagecrop/bug00297.c28
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagefile/gdnametest.c5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/CMakeLists.txt1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/Makemodule.am6
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting.c31
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting_exp.pngbin0 -> 379 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageflip/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageflip/Makemodule.am11
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflip.c37
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipboth_exp.pngbin0 -> 30307 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimagefliphorizontal_exp.pngbin0 -> 30297 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipvertical_exp.pngbin0 -> 30405 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageflip/remi.pngbin0 -> 49446 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/Makemodule.am9
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.c29
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.pngbin0 -> 2009 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic_exp.pngbin0 -> 2092 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimageline/CMakeLists.txt2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagenegate/CMakeLists.txt5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagenegate/Makemodule.am9
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.c29
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.pngbin0 -> 2009 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic_exp.pngbin0 -> 2014 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerectangle/CMakeLists.txt2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerectangle/Makemodule.am7
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299.c32
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299_exp.pngbin0 -> 133 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerectangle/point_ordering.c76
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerotate/CMakeLists.txt1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerotate/Makemodule.am5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.c35
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.gifbin0 -> 8424 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070_exp.pngbin0 -> 32722 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagescale/CMakeLists.txt2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagescale/Makemodule.am2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00329.c53
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00330.c32
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/CMakeLists.txt1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/Makemodule.am4
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alpha_blending.c54
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alphablending_exp.pngbin0 -> 682 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagestringft/gdimagestringft_bbox.c1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagestringftex/gdimagestringftex_returnfontpathname.c1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/CMakeLists.txt7
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/Makemodule.am9
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/bug00307.c26
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.c38
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.jpegbin0 -> 13608 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_72512.c2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdtest/CMakeLists.txt3
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdtest/Makemodule.am3
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c5
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h3
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdtest/test_config.h.cmake4
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gif/bug00006.c4
-rw-r--r--Build/source/libs/gd/libgd-src/tests/test_config.h.in9
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/CMakeLists.txt2
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/Makemodule.am11
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/heap_overflow.c59
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_1.tgabin0 -> 605 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_2.tgabin0 -> 8746 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/tga_read.c40
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.pngbin0 -> 2349 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.tgabin0 -> 90444 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb_rle.tgabin0 -> 9987 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tiff/CMakeLists.txt1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tiff/Makemodule.am6
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tiff/tiff_dpi.c6
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read.c61
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_1.tiffbin0 -> 3304 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_2.tiffbin0 -> 429 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_3.tiffbin0 -> 428 bytes
-rw-r--r--Build/source/libs/gd/libgd-src/tests/webp/CMakeLists.txt1
-rw-r--r--Build/source/libs/gd/libgd-src/tests/webp/Makemodule.am6
-rw-r--r--Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.c29
-rw-r--r--Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.jpgbin0 -> 576 bytes
133 files changed, 1458 insertions, 58 deletions
diff --git a/Build/source/libs/gd/libgd-src/tests/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/CMakeLists.txt
index 3c1402c57dc..7eef4bf46eb 100644
--- a/Build/source/libs/gd/libgd-src/tests/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/CMakeLists.txt
@@ -19,19 +19,26 @@ if (BUILD_TEST)
SET(TESTS_DIRS
bmp
+ fontconfig
freetype
gd
gd2
gdimagearc
+ gdimagebrightness
+ gdimageclone
+ gdimagecolor
gdimagecolorclosest
gdimagecolordeallocate
gdimagecolorexact
gdimagecolorreplace
gdimagecolorresolve
gdimagecolortransparent
+ gdimagecontrast
+ gdimageconvolution
gdimagecopy
gdimagecopyresampled
gdimagecopyrotated
+ gdimagecreate
gdimagecrop
gdimagefile
gdimagefill
@@ -41,7 +48,10 @@ if (BUILD_TEST)
gdimagefilledrectangle
gdimagefilltoborder
gdimagefilter
+ gdimageflip
+ gdimagegrayscale
gdimageline
+ gdimagenegate
gdimageopenpolygon
gdimagepixelate
gdimagepolygon
diff --git a/Build/source/libs/gd/libgd-src/tests/Makefile.am b/Build/source/libs/gd/libgd-src/tests/Makefile.am
index afdcd5d6a0a..5f8b624bc1c 100644
--- a/Build/source/libs/gd/libgd-src/tests/Makefile.am
+++ b/Build/source/libs/gd/libgd-src/tests/Makefile.am
@@ -4,6 +4,7 @@ libgdtest_a_SOURCES = \
gdtest/gdtest.c \
gdtest/gdtest.h \
gdhelpers.c
+libgdtest_a_CPPFLAGS = $(AM_CPPFLAGS) -DGDTEST_TOP_DIR='"$(srcdir)"'
# Setup vars that subdirs will increment.
libgd_test_programs =
@@ -13,19 +14,26 @@ EXTRA_DIST =
TESTS =
include bmp/Makemodule.am
+include fontconfig/Makemodule.am
include freetype/Makemodule.am
include gd/Makemodule.am
include gd2/Makemodule.am
include gdimagearc/Makemodule.am
+include gdimagebrightness/Makemodule.am
+include gdimageclone/Makemodule.am
+include gdimagecolor/Makemodule.am
include gdimagecolorclosest/Makemodule.am
include gdimagecolordeallocate/Makemodule.am
include gdimagecolorexact/Makemodule.am
include gdimagecolorreplace/Makemodule.am
include gdimagecolorresolve/Makemodule.am
include gdimagecolortransparent/Makemodule.am
+include gdimagecontrast/Makemodule.am
+include gdimageconvolution/Makemodule.am
include gdimagecopy/Makemodule.am
include gdimagecopyresampled/Makemodule.am
include gdimagecopyrotated/Makemodule.am
+include gdimagecreate/Makemodule.am
include gdimagecrop/Makemodule.am
include gdimagefile/Makemodule.am
include gdimagefill/Makemodule.am
@@ -35,7 +43,10 @@ include gdimagefilledpolygon/Makemodule.am
include gdimagefilledrectangle/Makemodule.am
include gdimagefilltoborder/Makemodule.am
include gdimagefilter/Makemodule.am
+include gdimageflip/Makemodule.am
+include gdimagegrayscale/Makemodule.am
include gdimageline/Makemodule.am
+include gdimagenegate/Makemodule.am
include gdimageopenpolygon/Makemodule.am
include gdimagepixelate/Makemodule.am
include gdimagepolygon/Makemodule.am
@@ -63,7 +74,7 @@ include xbm/Makemodule.am
include xpm/Makemodule.am
LDADD = libgdtest.a ../src/libgd.la
-AM_CPPFLAGS = -I$(top_srcdir)/src -I $(top_srcdir)/tests/gdtest
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/tests/gdtest
check_PROGRAMS = $(libgd_test_programs) $(libgd_helper_programs)
TESTS += $(libgd_test_programs)
diff --git a/Build/source/libs/gd/libgd-src/tests/bmp/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/bmp/CMakeLists.txt
index 9c7800e9a67..a42629b8bcf 100644
--- a/Build/source/libs/gd/libgd-src/tests/bmp/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/bmp/CMakeLists.txt
@@ -1,6 +1,8 @@
SET(TESTS_FILES
bmp_im2im
bmp_null
+ bug00275
+ bug00276
)
ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/bmp/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/bmp/Makemodule.am
index 73be361bede..27dc7ecd00a 100644
--- a/Build/source/libs/gd/libgd-src/tests/bmp/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/bmp/Makemodule.am
@@ -1,5 +1,7 @@
libgd_test_programs += \
- bmp/bmp_null
+ bmp/bmp_null \
+ bmp/bug00275 \
+ bmp/bug00276
if HAVE_LIBPNG
libgd_test_programs += \
diff --git a/Build/source/libs/gd/libgd-src/tests/bmp/bug00275.c b/Build/source/libs/gd/libgd-src/tests/bmp/bug00275.c
new file mode 100644
index 00000000000..710c084c877
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/bmp/bug00275.c
@@ -0,0 +1,53 @@
+/* See <https://github.com/libgd/libgd/issues/275>. */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+#ifdef __GNUC__
+#define UNUSED __attribute__((unused))
+#else
+#define UNUSED
+#endif
+
+
+/* define callbacks for a non-seekable fake IO context */
+
+static void fakePutC(UNUSED gdIOCtx *ctx, UNUSED int c)
+{
+ // do nothing
+}
+
+static int fakePutBuf(UNUSED gdIOCtx *ctx, UNUSED const void *data, int wanted)
+{
+ return wanted;
+}
+
+
+int main()
+{
+ gdImagePtr im;
+ int white;
+ gdIOCtx ctx;
+
+ /* initialize the fake IO context */
+ ctx.getC = NULL;
+ ctx.getBuf = NULL;
+ ctx.putC = fakePutC;
+ ctx.putBuf = fakePutBuf;
+ ctx.seek = NULL;
+ ctx.tell = NULL;
+ ctx.gd_free = NULL;
+
+ /* create an image */
+ im = gdImageCreate(10, 10);
+ gdImageColorAllocate(im, 0, 0, 0);
+ white = gdImageColorAllocate(im, 255, 255, 255);
+ gdImageLine(im, 2,2, 7,7, white);
+
+ /* "save" the image as BMP */
+ gdImageBmpCtx(im, &ctx, 2);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/bmp/bug00276.c b/Build/source/libs/gd/libgd-src/tests/bmp/bug00276.c
new file mode 100644
index 00000000000..58ca423b7ee
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/bmp/bug00276.c
@@ -0,0 +1,32 @@
+/* See <https://github.com/libgd/libgd/issues/276> */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im_orig, im_saved;
+ int white;
+ void *data;
+ int size;
+
+ /* create an image */
+ im_orig = gdImageCreate(10, 10);
+ gdImageColorAllocate(im_orig, 0, 0, 0);
+ white = gdImageColorAllocate(im_orig, 255, 255, 255);
+ gdImageLine(im_orig, 0,0, 9,9, white);
+
+ /* save the image, re-read it and compare it with the original */
+ data = gdImageBmpPtr(im_orig, &size, 1);
+ im_saved = gdImageCreateFromBmpPtr(size, data);
+ gdTestAssert(im_saved != NULL);
+ gdAssertImageEquals(im_orig, im_saved);
+
+ /* clean up */
+ gdImageDestroy(im_orig);
+ gdImageDestroy(im_saved);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/fontconfig/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/fontconfig/CMakeLists.txt
new file mode 100644
index 00000000000..159130dffb2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/fontconfig/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(FREETYPE_FOUND AND FONTCONFIG_FOUND)
+LIST(APPEND TESTS_FILES
+ basic
+)
+ENDIF(FREETYPE_FOUND AND FONTCONFIG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/fontconfig/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/fontconfig/Makemodule.am
new file mode 100644
index 00000000000..cbde85b4464
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/fontconfig/Makemodule.am
@@ -0,0 +1,9 @@
+if HAVE_LIBFONTCONFIG
+if HAVE_LIBFREETYPE
+libgd_test_programs += \
+ fontconfig/basic
+endif
+endif
+
+EXTRA_DIST += \
+ fontconfig/CMakeLists.txt
diff --git a/Build/source/libs/gd/libgd-src/tests/fontconfig/basic.c b/Build/source/libs/gd/libgd-src/tests/fontconfig/basic.c
new file mode 100644
index 00000000000..71d24fb60a3
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/fontconfig/basic.c
@@ -0,0 +1,33 @@
+/**
+ * A most basic test for fontconfig support.
+ *
+ * Without actually using fontconfig, passing an empty fontlist to
+ * gdImageStringFT() would return an error ("Could not find/open font").
+ * We're checking that it returns NULL.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ int black;
+ char *error;
+
+ im = gdImageCreate(100, 100);
+ gdTestAssert(im != NULL);
+ gdImageColorAllocate(im, 255, 255, 255);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+
+ gdTestAssert(gdFTUseFontConfig(1));
+ error = gdImageStringFT(im, NULL, black, "", 14.0, 0.0, 10, 20, "foo");
+ gdTestAssertMsg(error == NULL, "%s", error);
+
+ gdImageDestroy(im);
+ gdFontCacheShutdown();
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/freetype/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/freetype/CMakeLists.txt
index 83bb18d754d..728c226c661 100644
--- a/Build/source/libs/gd/libgd-src/tests/freetype/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/freetype/CMakeLists.txt
@@ -1,6 +1,6 @@
IF(FREETYPE_FOUND)
SET(TESTS_FILES
-# bug00132
+ bug00132
)
ENDIF(FREETYPE_FOUND)
diff --git a/Build/source/libs/gd/libgd-src/tests/freetype/bug00132.c b/Build/source/libs/gd/libgd-src/tests/freetype/bug00132.c
index 2c3d6bc8103..713dd2d023f 100644
--- a/Build/source/libs/gd/libgd-src/tests/freetype/bug00132.c
+++ b/Build/source/libs/gd/libgd-src/tests/freetype/bug00132.c
@@ -34,5 +34,6 @@ int main()
}
}
gdImageDestroy(im);
+ gdFontCacheShutdown();
return error;
}
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gd2/CMakeLists.txt
index 8aecacc7fd5..8c27babea2c 100644
--- a/Build/source/libs/gd/libgd-src/tests/gd2/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/CMakeLists.txt
@@ -1,8 +1,12 @@
SET(TESTS_FILES
+ bug_289
+ bug00309
+ bug00354
gd2_empty_file
gd2_im2im
gd2_null
php_bug_72339
+ too_few_image_data
)
ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gd2/Makemodule.am
index 4c0199039eb..add4f34a76f 100644
--- a/Build/source/libs/gd/libgd-src/tests/gd2/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/Makemodule.am
@@ -1,7 +1,11 @@
libgd_test_programs += \
+ gd2/bug_289 \
+ gd2/bug00309 \
+ gd2/bug00354 \
gd2/gd2_empty_file \
gd2/php_bug_72339 \
- gd2/gd2_read_corrupt
+ gd2/gd2_read_corrupt \
+ gd2/too_few_image_data
if HAVE_LIBZ
libgd_test_programs += \
@@ -16,10 +20,12 @@ endif
EXTRA_DIST += \
gd2/CMakeLists.txt \
+ gd2/bug00354a.gd2 \
+ gd2/bug00354b.gd2 \
gd2/conv_gd2_exp.gd2 \
gd2/conv_test.gd2 \
gd2/conv_test_exp.png \
gd2/empty.gd2 \
gd2/invalid_header.gd2 \
gd2/invalid_neg_size.gd2 \
- gd2/php_bug_72339_exp.gd2
+ gd2/too_few_image_data.gd2
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/bug00309.c b/Build/source/libs/gd/libgd-src/tests/gd2/bug00309.c
new file mode 100644
index 00000000000..b649cdc2d63
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/bug00309.c
@@ -0,0 +1,37 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/309>.
+ *
+ * We test that an image with 64x64 pixels reports only a single chunk in the
+ * GD2 image header when the chunk size is 64.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ unsigned char *buf;
+ int size, word;
+
+ im = gdImageCreate(64, 64);
+ gdImageColorAllocate(im, 0, 0, 0);
+
+ buf = gdImageGd2Ptr(im, 64, 1, &size);
+
+ gdImageDestroy(im);
+
+ word = buf[10] << 8 | buf[11];
+ gdTestAssertMsg(word == 64, "chunk size is %d, but expected 64\n", word);
+ word = buf[14] << 8 | buf[15];
+ gdTestAssertMsg(word == 1, "x chunk count is %d, but expected 1\n", word);
+ word = buf[16] << 8 | buf[17];
+ gdTestAssertMsg(word == 1, "y chunk count is %d, but expected 1\n", word);
+ gdTestAssertMsg(size == 5145, "file size is %d, but expected 5145\n", size);
+
+ gdFree(buf);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/bug00354.c b/Build/source/libs/gd/libgd-src/tests/gd2/bug00354.c
new file mode 100644
index 00000000000..8dc27cc5ad0
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/bug00354.c
@@ -0,0 +1,32 @@
+/**
+ * We're testing GD2 image files which report illegal chunk counts. These should
+ * not cause integer overflows or other issues, but instead simply fail to be
+ * loaded.
+ *
+ * See also <https://github.com/libgd/libgd/issues/354>.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gd2", "bug00354a.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ fp = gdTestFileOpen2("gd2", "bug00354b.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/bug00354a.gd2 b/Build/source/libs/gd/libgd-src/tests/gd2/bug00354a.gd2
new file mode 100644
index 00000000000..5060bfde3aa
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/bug00354a.gd2
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/bug00354b.gd2 b/Build/source/libs/gd/libgd-src/tests/gd2/bug00354b.gd2
new file mode 100644
index 00000000000..8600126becb
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/bug00354b.gd2
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/bug_289.c b/Build/source/libs/gd/libgd-src/tests/gd2/bug_289.c
new file mode 100644
index 00000000000..ad311e93ebc
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/bug_289.c
@@ -0,0 +1,33 @@
+/**
+ * Passing an unrecognized format to gdImageGd2() should result in
+ * GD2_FMT_TRUECOLOR_COMPRESSED for truecolor images.
+ *
+ * See <https://github.com/libgd/libgd/issues/289>.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+#define GD2_FMT_UNRECOGNIZED 0
+#define GD2_FMT_TRUECOLOR_COMPRESSED 4
+
+#define MSG "expected %s byte to be %d, but got %d\n"
+
+
+int main()
+{
+ gdImagePtr im;
+ char *buffer;
+ int size;
+
+ im = gdImageCreateTrueColor(10, 10);
+ gdTestAssert(im != NULL);
+ buffer = (char *) gdImageGd2Ptr(im, 128, GD2_FMT_UNRECOGNIZED, &size);
+ gdTestAssert(buffer != NULL);
+ gdImageDestroy(im);
+ gdTestAssertMsg(buffer[12] == 0, MSG, "1st", 0, buffer[12]);
+ gdTestAssertMsg(buffer[13] == GD2_FMT_TRUECOLOR_COMPRESSED, MSG, "2nd", GD2_FMT_TRUECOLOR_COMPRESSED, buffer[13]);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339.c b/Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339.c
index e15383e8c75..7ce60289ef8 100644
--- a/Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339.c
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339.c
@@ -8,14 +8,29 @@ int main()
{
gdImagePtr im;
FILE *fp;
-
- fp = gdTestFileOpen2("gd2", "php_bug_72339_exp.gd2");
- im = gdImageCreateFromGd2(fp);
- if (im == NULL) {
- return 0;
- } else {
- gdTestErrorMsg("Image should have failed to be loaded");
- return 1;
+ int i;
+ const char header[] = {
+ 0x00, 0x02,
+ 0x00, 0x01,
+ 0x00, 0x01,
+ 0x00, 0x40,
+ 0x00, 0x02,
+ 0x54, 0xA0,
+ 0x5B, 0x00
+ };
+
+ /* we're creating the test image dynamically, due to its size */
+ fp = gdTestTempFp();
+ fwrite(header, sizeof(header[0]), sizeof(header), fp);
+ for (i = 0; i < 0x4000000; i++) {
+ fputc(0x41, fp);
}
+ rewind(fp);
+
+ im = gdImageCreateFromGd2(fp);
+ fclose(fp);
+
+ gdTestAssertMsg(im == NULL, "Image should have failed to be loaded\n");
+ return gdNumFailures();
}
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339_exp.gd2 b/Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339_exp.gd2
deleted file mode 100644
index 39ed2270390..00000000000
--- a/Build/source/libs/gd/libgd-src/tests/gd2/php_bug_72339_exp.gd2
+++ /dev/null
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.c b/Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.c
new file mode 100644
index 00000000000..3153a080078
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.c
@@ -0,0 +1,22 @@
+/*
+too_few_image_data.gd2 claims to have a size of 12336x48 pixels, but doesn't
+provide as much image data. We test that gdImageCreateFromGd2Ctx() returns NULL
+in this case.
+*/
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gd2", "too_few_image_data.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.gd2 b/Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.gd2
new file mode 100644
index 00000000000..1c797d1acfa
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gd2/too_few_image_data.gd2
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/CMakeLists.txt
new file mode 100644
index 00000000000..381c74d06e2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/Makemodule.am
new file mode 100644
index 00000000000..142fd948484
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/Makemodule.am
@@ -0,0 +1,10 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagebrightness/basic
+endif
+
+EXTRA_DIST += \
+ gdimagebrightness/CMakeLists.txt \
+ gdimagebrightness/basic.png \
+ gdimagebrightness/basic+100.png \
+ gdimagebrightness/basic-100.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic+100.png b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic+100.png
new file mode 100644
index 00000000000..5ed328916ff
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic+100.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic-100.png b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic-100.png
new file mode 100644
index 00000000000..80c2997905d
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic-100.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.c b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.c
new file mode 100644
index 00000000000..779704830f0
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.c
@@ -0,0 +1,41 @@
+/**
+ * Basic test for gdImageBrightness()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test_brightness(int brightness);
+
+
+int main()
+{
+ test_brightness(+100);
+ test_brightness(-100);
+
+ return gdNumFailures();
+}
+
+
+static void test_brightness(int brightness)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char basename[256];
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagebrightness", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageBrightness(im, brightness);
+
+ sprintf(basename, "basic%+03d.png", brightness);
+ path = gdTestFilePath2("gdimagebrightness", basename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.png b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.png
new file mode 100644
index 00000000000..517010b42ff
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagebrightness/basic.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageclone/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimageclone/CMakeLists.txt
new file mode 100644
index 00000000000..e6ccc318a0f
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageclone/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ bug00300
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageclone/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimageclone/Makemodule.am
new file mode 100644
index 00000000000..4b1b54c0100
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageclone/Makemodule.am
@@ -0,0 +1,5 @@
+libgd_test_programs += \
+ gdimageclone/bug00300
+
+EXTRA_DIST += \
+ gdimageclone/CMakeLists.txt
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageclone/bug00300.c b/Build/source/libs/gd/libgd-src/tests/gdimageclone/bug00300.c
new file mode 100644
index 00000000000..c5b7bde1724
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageclone/bug00300.c
@@ -0,0 +1,32 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/300>
+ *
+ * We're testing that the resolution does not change when cloning.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im, clone;
+
+ im = gdImageCreate(8, 8);
+ gdImageSetResolution(im, 100, 50);
+
+ clone = gdImageClone(im);
+
+ gdTestAssertMsg(gdImageResolutionX(clone) == gdImageResolutionX(im),
+ "horizontal resolution doesn't match: expected %d, got %d\n",
+ gdImageResolutionX(im), gdImageResolutionX(clone));
+ gdTestAssertMsg(gdImageResolutionY(clone) == gdImageResolutionY(im),
+ "vertical resolution doesn't match: expected %d, got %d\n",
+ gdImageResolutionY(im), gdImageResolutionY(clone));
+
+ gdImageDestroy(clone);
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecolor/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/CMakeLists.txt
new file mode 100644
index 00000000000..381c74d06e2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecolor/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/Makemodule.am
new file mode 100644
index 00000000000..caf26a4d487
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/Makemodule.am
@@ -0,0 +1,9 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecolor/basic
+endif
+
+EXTRA_DIST += \
+ gdimagecolor/CMakeLists.txt \
+ gdimagecolor/basic.png \
+ gdimagecolor/basic_exp.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.c b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.c
new file mode 100644
index 00000000000..ff2fe349854
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.c
@@ -0,0 +1,29 @@
+/**
+ * Basic test for gdImageColor()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagecolor", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageColor(im, 127, -127, -127, 0);
+
+ path = gdTestFilePath2("gdimagecolor", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.png b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.png
new file mode 100644
index 00000000000..310f4ae89ed
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic_exp.png
new file mode 100644
index 00000000000..0af32508bc6
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecolor/basic_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/CMakeLists.txt
new file mode 100644
index 00000000000..381c74d06e2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/Makemodule.am
new file mode 100644
index 00000000000..635e2dc46a1
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/Makemodule.am
@@ -0,0 +1,10 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecontrast/basic
+endif
+
+EXTRA_DIST += \
+ gdimagecontrast/CMakeLists.txt \
+ gdimagecontrast/basic.png \
+ gdimagecontrast/basic+50.png \
+ gdimagecontrast/basic-50.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic+50.png b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic+50.png
new file mode 100644
index 00000000000..d2a85ed6249
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic+50.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic-50.png b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic-50.png
new file mode 100644
index 00000000000..94151ecaff7
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic-50.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.c b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.c
new file mode 100644
index 00000000000..66c17ab9fb9
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.c
@@ -0,0 +1,41 @@
+/**
+ * Basic test for gdImageContrast()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test_contrast(double contrast);
+
+
+int main()
+{
+ test_contrast(+50.0);
+ test_contrast(-50.0);
+
+ return gdNumFailures();
+}
+
+
+static void test_contrast(double contrast)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char basename[256];
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagecontrast", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageContrast(im, contrast);
+
+ sprintf(basename, "basic%+03.0f.png", contrast);
+ path = gdTestFilePath2("gdimagecontrast", basename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.png b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.png
new file mode 100644
index 00000000000..517010b42ff
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecontrast/basic.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/CMakeLists.txt
new file mode 100644
index 00000000000..381c74d06e2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/Makemodule.am
new file mode 100644
index 00000000000..8f65b0f36e9
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/Makemodule.am
@@ -0,0 +1,12 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimageconvolution/basic
+endif
+
+EXTRA_DIST += \
+ gdimageconvolution/CMakeLists.txt \
+ gdimageconvolution/basic.png \
+ gdimageconvolution/basic_edge_detect_quick.png \
+ gdimageconvolution/basic_emboss.png \
+ gdimageconvolution/basic_mean_removal.png \
+ gdimageconvolution/basic_smooth.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.c b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.c
new file mode 100644
index 00000000000..267a079d898
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.c
@@ -0,0 +1,62 @@
+/**
+ * Basic test for gdImageConvolution() and related functions
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test_convolution(void (*convolution_func)(gdImagePtr im), const char *expected)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimageconvolution", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ convolution_func(im);
+
+ path = gdTestFilePath2("gdimageconvolution", expected);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
+
+
+static void test_edge_detect_quick(gdImagePtr im)
+{
+ gdImageEdgeDetectQuick(im);
+}
+
+
+static void test_smooth(gdImagePtr im)
+{
+ gdImageSmooth(im, 5);
+}
+
+
+static void test_emboss(gdImagePtr im)
+{
+ gdImageEmboss(im);
+}
+
+
+static void test_mean_removal(gdImagePtr im)
+{
+ gdImageMeanRemoval(im);
+}
+
+
+int main()
+{
+ test_convolution(&test_edge_detect_quick, "basic_edge_detect_quick.png");
+ test_convolution(&test_smooth, "basic_smooth.png");
+ test_convolution(&test_emboss, "basic_emboss.png");
+ test_convolution(&test_mean_removal, "basic_mean_removal.png");
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.png b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.png
new file mode 100644
index 00000000000..2db78821ab8
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_edge_detect_quick.png b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_edge_detect_quick.png
new file mode 100644
index 00000000000..195a0fdcdf2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_edge_detect_quick.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_emboss.png b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_emboss.png
new file mode 100644
index 00000000000..bafd88233f5
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_emboss.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_mean_removal.png b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_mean_removal.png
new file mode 100644
index 00000000000..e98a91ac821
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_mean_removal.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_smooth.png b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_smooth.png
new file mode 100644
index 00000000000..7907143fd63
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageconvolution/basic_smooth.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecopyrotated/bug00020.c b/Build/source/libs/gd/libgd-src/tests/gdimagecopyrotated/bug00020.c
index fe8dfdf451d..4933df00376 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagecopyrotated/bug00020.c
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecopyrotated/bug00020.c
@@ -7,7 +7,6 @@ int main()
{
gdImagePtr im, im2;
int error = 0;
- char *path;
im = gdImageCreateTrueColor(width, width);
gdImageFilledRectangle(im, 0,0, width, width, 0xFF0000);
@@ -18,13 +17,11 @@ int main()
im2 = gdImageCreateTrueColor(width, width);
gdImageCopyRotated(im2, im, width / 2, width / 2, 0,0, width, width, 60);
- path = gdTestFilePath2("gdimagecopyrotated", "bug00020_exp.png");
- if (!gdAssertImageEqualsToFile(path, im2)) {
+ if (!gdAssertImageEqualsToFile("gdimagecopyrotated/bug00020_exp.png", im2)) {
error = 1;
}
gdImageDestroy(im2);
gdImageDestroy(im);
- free(path);
return error;
}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecreate/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagecreate/CMakeLists.txt
new file mode 100644
index 00000000000..905e79c52e2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecreate/CMakeLists.txt
@@ -0,0 +1,5 @@
+SET(TESTS_FILES
+ bug00340
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecreate/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagecreate/Makemodule.am
new file mode 100644
index 00000000000..886608694af
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecreate/Makemodule.am
@@ -0,0 +1,5 @@
+libgd_test_programs += \
+ gdimagecreate/bug00340
+
+EXTRA_DIST += \
+ gdimagecreate/CMakeLists.txt
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecreate/bug00340.c b/Build/source/libs/gd/libgd-src/tests/gdimagecreate/bug00340.c
new file mode 100644
index 00000000000..14129ab8660
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecreate/bug00340.c
@@ -0,0 +1,33 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/340>
+ *
+ * We're testing that trying to create an oversized image fails early,
+ * triggering an appropriate warning.
+ */
+
+
+#include <string.h>
+#include "gd.h"
+#include "gd_errors.h"
+#include "gdtest.h"
+
+
+#define MSG "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n"
+
+
+void error_handler(int priority, const char *format, ...)
+{
+ gdTestAssert(priority == GD_WARNING);
+ gdTestAssert(!strcmp(format, MSG));
+}
+
+
+int main()
+{
+ gdImagePtr im;
+
+ im = gdImageCreate(64970, 65111);
+ gdTestAssert(im == NULL);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecrop/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagecrop/CMakeLists.txt
index f7e4c7ef475..4b1e97e292c 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagecrop/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecrop/CMakeLists.txt
@@ -1,4 +1,5 @@
SET(TESTS_FILES
+ bug00297
php_bug_72494
)
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecrop/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagecrop/Makemodule.am
index 210888b5a70..fe73c1de929 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagecrop/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecrop/Makemodule.am
@@ -1,4 +1,5 @@
libgd_test_programs += \
+ gdimagecrop/bug00297 \
gdimagecrop/php_bug_72494
EXTRA_DIST += \
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagecrop/bug00297.c b/Build/source/libs/gd/libgd-src/tests/gdimagecrop/bug00297.c
new file mode 100644
index 00000000000..5ce99604468
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagecrop/bug00297.c
@@ -0,0 +1,28 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/297>.
+ *
+ * We're testing that the result of gdImageCrop() is a palette image,
+ * if the source was also a palette image.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ gdRect rect = {0, 0, 8, 8};
+
+ src = gdImageCreate(8, 8);
+ dst = gdImageCrop(src, &rect);
+
+ gdTestAssert(!gdImageTrueColor(src));
+ gdTestAssert(!gdImageTrueColor(dst));
+
+ gdImageDestroy(dst);
+ gdImageDestroy(src);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagefile/gdnametest.c b/Build/source/libs/gd/libgd-src/tests/gdimagefile/gdnametest.c
index 40dbc30b9e3..66da484e821 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagefile/gdnametest.c
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagefile/gdnametest.c
@@ -4,7 +4,6 @@
#include "gd.h"
#include "gdtest.h"
-#include "test_config.h"
#define WIDTH 60
#define HEIGHT 50
@@ -50,8 +49,8 @@ gdImagePtr mkcross() {
void
do_test() {
- gdTestAssertMsg(strchr("123",'2') != 0, "strchr() is not functional.\n",1);
- gdTestAssertMsg(strcasecmp("123abC","123Abc") == 0, "strcasecmp() is not functional.\n",1);
+ gdTestAssertMsg(strchr("123",'2') != 0, "strchr() is not functional.\n");
+ gdTestAssertMsg(strcasecmp("123abC","123Abc") == 0, "strcasecmp() is not functional.\n");
int n;
struct {
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/CMakeLists.txt
index 1a2d3305f5e..190dad7f943 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/CMakeLists.txt
@@ -5,6 +5,7 @@ SET(TESTS_FILES
gdimagefilledpolygon3
bug00100
php_bug_64641
+ self_intersecting
)
ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/Makemodule.am
index 7a2f6812bbf..03c48462b3d 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/Makemodule.am
@@ -5,7 +5,8 @@ libgd_test_programs += \
gdimagefilledpolygon/gdimagefilledpolygon1 \
gdimagefilledpolygon/gdimagefilledpolygon2 \
gdimagefilledpolygon/gdimagefilledpolygon3 \
- gdimagefilledpolygon/php_bug_64641
+ gdimagefilledpolygon/php_bug_64641 \
+ gdimagefilledpolygon/self_intersecting
endif
EXTRA_DIST += \
@@ -15,4 +16,5 @@ EXTRA_DIST += \
gdimagefilledpolygon/gdimagefilledpolygon1.png \
gdimagefilledpolygon/gdimagefilledpolygon2.png \
gdimagefilledpolygon/gdimagefilledpolygon3.png \
- gdimagefilledpolygon/php_bug_64641.png
+ gdimagefilledpolygon/php_bug_64641.png \
+ gdimagefilledpolygon/self_intersecting_exp.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting.c b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting.c
new file mode 100644
index 00000000000..ebb1404984d
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting.c
@@ -0,0 +1,31 @@
+/**
+ * We're testing the filling behavior of self-intersecting polygons, which is
+ * *currently* using the even-odd fillrule.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ int black;
+ gdPoint points[] = {{50, 5}, {24, 86}, {93, 36}, {7, 36}, {76, 86}};
+ char *path;
+
+ im = gdImageCreate(100, 100);
+ gdImageColorAllocate(im, 255, 255, 255);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+
+ gdImageFilledPolygon(im, points, 5, black);
+
+ path = gdTestFilePath2("gdimagefilledpolygon", "self_intersecting_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting_exp.png
new file mode 100644
index 00000000000..907820ffe7f
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagefilledpolygon/self_intersecting_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageflip/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimageflip/CMakeLists.txt
new file mode 100644
index 00000000000..39caf080fb3
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageflip/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ gdimageflip
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageflip/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimageflip/Makemodule.am
new file mode 100644
index 00000000000..e3a1f8ea527
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageflip/Makemodule.am
@@ -0,0 +1,11 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimageflip/gdimageflip
+endif
+
+EXTRA_DIST += \
+ gdimageflip/CMakeLists.txt \
+ gdimageflip/remi.png \
+ gdimageflip/gdimageflipvertical_exp.png \
+ gdimageflip/gdimagefliphorizontal_exp.png \
+ gdimageflip/gdimageflipboth_exp.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflip.c b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflip.c
new file mode 100644
index 00000000000..e0a1a2ab3d7
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflip.c
@@ -0,0 +1,37 @@
+/**
+ * Testing the basic operation of the gdImageFlip*() functions
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test_flip(void (*func)(gdImagePtr), const char *filename)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimageflip", "remi.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ func(im);
+
+ path = gdTestFilePath2("gdimageflip", filename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
+
+
+int main()
+{
+ test_flip(gdImageFlipVertical, "gdimageflipvertical_exp.png");
+ test_flip(gdImageFlipHorizontal, "gdimagefliphorizontal_exp.png");
+ test_flip(gdImageFlipBoth, "gdimageflipboth_exp.png");
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipboth_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipboth_exp.png
new file mode 100644
index 00000000000..d9cb57681c8
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipboth_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimagefliphorizontal_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimagefliphorizontal_exp.png
new file mode 100644
index 00000000000..5e7c7f9b717
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimagefliphorizontal_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipvertical_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipvertical_exp.png
new file mode 100644
index 00000000000..383516393c9
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageflip/gdimageflipvertical_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageflip/remi.png b/Build/source/libs/gd/libgd-src/tests/gdimageflip/remi.png
new file mode 100644
index 00000000000..2db78821ab8
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageflip/remi.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/CMakeLists.txt
new file mode 100644
index 00000000000..381c74d06e2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/Makemodule.am
new file mode 100644
index 00000000000..e715c5b4235
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/Makemodule.am
@@ -0,0 +1,9 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagegrayscale/basic
+endif
+
+EXTRA_DIST += \
+ gdimagegrayscale/CMakeLists.txt \
+ gdimagegrayscale/basic.png \
+ gdimagegrayscale/basic_exp.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.c b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.c
new file mode 100644
index 00000000000..40b4201944a
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.c
@@ -0,0 +1,29 @@
+/**
+ * Basic test for gdImageGrayScale()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagegrayscale", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageGrayScale(im);
+
+ path = gdTestFilePath2("gdimagegrayscale", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.png b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.png
new file mode 100644
index 00000000000..517010b42ff
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic_exp.png
new file mode 100644
index 00000000000..310f4ae89ed
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagegrayscale/basic_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimageline/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimageline/CMakeLists.txt
index 61982517ede..a1658a61a04 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimageline/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimageline/CMakeLists.txt
@@ -1,6 +1,8 @@
SET(TESTS_FILES
gdimageline_aa
gdimageline_aa_outofrange
+ gdImageAALine_thickness
+ github_bug_167
bug00077
bug00072
bug00111
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagenegate/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/CMakeLists.txt
new file mode 100644
index 00000000000..381c74d06e2
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagenegate/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/Makemodule.am
new file mode 100644
index 00000000000..03b4dce1adb
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/Makemodule.am
@@ -0,0 +1,9 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagenegate/basic
+endif
+
+EXTRA_DIST += \
+ gdimagenegate/CMakeLists.txt \
+ gdimagenegate/basic.png \
+ gdimagenegate/basic_exp.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.c b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.c
new file mode 100644
index 00000000000..f8dafc8ea23
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.c
@@ -0,0 +1,29 @@
+/**
+ * Basic test for gdImageNegate()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagenegate", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageNegate(im);
+
+ path = gdTestFilePath2("gdimagenegate", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.png b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.png
new file mode 100644
index 00000000000..517010b42ff
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic_exp.png
new file mode 100644
index 00000000000..2dc0484d018
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagenegate/basic_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/CMakeLists.txt
index 517864ed2ba..9008d86c77f 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/CMakeLists.txt
@@ -1,7 +1,9 @@
SET(TESTS_FILES
bug00003
bug00106_gdimagerectangle
+ bug00299
github_bug_00172
+ point_ordering
)
ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/Makemodule.am
index 4175ca59873..ea9d52b9662 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/Makemodule.am
@@ -1,7 +1,10 @@
libgd_test_programs += \
gdimagerectangle/bug00003 \
gdimagerectangle/bug00106_gdimagerectangle \
- gdimagerectangle/github_bug_00172
+ gdimagerectangle/bug00299 \
+ gdimagerectangle/github_bug_00172 \
+ gdimagerectangle/point_ordering
EXTRA_DIST += \
- gdimagerectangle/CMakeLists.txt
+ gdimagerectangle/CMakeLists.txt \
+ gdimagerectangle/bug00299_exp.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299.c b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299.c
new file mode 100644
index 00000000000..7e604cee941
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299.c
@@ -0,0 +1,32 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/299>
+ *
+ * We test that thick rectangles are drawn as desired.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ int black;
+
+ im = gdImageCreate(70, 70);
+ gdImageColorAllocate(im, 255, 255, 255);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageSetThickness(im, 4);
+
+ gdImageRectangle(im, 10,10, 50,50, black);
+ gdImageRectangle(im, 10,60, 50,60, black);
+ gdImageRectangle(im, 60,10, 60,50, black);
+ gdImageRectangle(im, 60,60, 60,60, black);
+
+ gdAssertImageEqualsToFile("gdimagerectangle/bug00299_exp.png", im);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299_exp.png
new file mode 100644
index 00000000000..6ebdba64d72
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/bug00299_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/point_ordering.c b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/point_ordering.c
new file mode 100644
index 00000000000..b2ea4ed1735
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerectangle/point_ordering.c
@@ -0,0 +1,76 @@
+/**
+ * Test point ordering of gdImageRectangle()
+ *
+ * We're testing the two allowed point orders with and without thickness,
+ * and verify that all sides of the rectangle are drawn.
+ *
+ * See also <https://github.com/libgd/libgd/issues/177>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void draw_and_check_rectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int black, int red);
+static void draw_and_check_pixel(gdImagePtr im, int x, int y, int black, int red);
+
+
+int main()
+{
+ gdImagePtr im;
+ int black, red;
+
+ im = gdImageCreate(110, 210);
+ gdImageColorAllocate(im, 255, 255, 255);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ red = gdImageColorAllocate(im, 255, 0, 0);
+
+ draw_and_check_rectangle(im, 10, 10, 50, 50, black, red);
+ draw_and_check_rectangle(im, 50, 150, 10, 110, black, red);
+ gdImageSetThickness(im, 4);
+ draw_and_check_rectangle(im, 60, 10, 100, 50, black, red);
+ draw_and_check_rectangle(im, 100, 150, 60, 110, black, red);
+
+#if 0
+ /* save image for debugging purposes */
+ do {
+ char *path;
+ FILE *fp;
+
+ path = gdTestFilePath2("gdimagerectangle", "point_ordering.png");
+ fp = fopen(path, "wb");
+ gdImagePng(im, fp);
+ fclose(fp);
+ gdFree(path);
+ } while(0);
+#endif
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
+
+
+static void draw_and_check_rectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int black, int red)
+{
+ int x, y;
+
+ gdImageRectangle(im, x1, y1, x2, y2, black);
+ x = (x1 + x2) / 2;
+ y = (y1 + y2) / 2;
+ draw_and_check_pixel(im, x, y1, black, red);
+ draw_and_check_pixel(im, x1, y, black, red);
+ draw_and_check_pixel(im, x, y2, black, red);
+ draw_and_check_pixel(im, x2, y, black, red);
+}
+
+
+static void draw_and_check_pixel(gdImagePtr im, int x, int y, int black, int red)
+{
+ int color;
+
+ color = gdImagePalettePixel(im, x, y);
+ gdTestAssertMsg(color == black, "expected color %d, but got color %d\n", black, color);
+ gdImageSetPixel(im, x, y, red);
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerotate/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/CMakeLists.txt
index fd8b4fa7b1b..ab8b4cfb7ca 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagerotate/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/CMakeLists.txt
@@ -1,6 +1,7 @@
SET(TESTS_FILES
bug00067
php_bug_64898
+ php_bug_65070
)
ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerotate/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/Makemodule.am
index 696344bafb5..99b2398bb8a 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagerotate/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/Makemodule.am
@@ -5,7 +5,8 @@ endif
if HAVE_LIBPNG
libgd_test_programs += \
- gdimagerotate/php_bug_64898
+ gdimagerotate/php_bug_64898 \
+ gdimagerotate/php_bug_65070
endif
EXTRA_DIST += \
@@ -25,4 +26,6 @@ EXTRA_DIST += \
gdimagerotate/bug00067_180_exp.png \
gdimagerotate/php_bug_64898.png \
gdimagerotate/php_bug_64898_exp.png \
+ gdimagerotate/php_bug_65070.gif \
+ gdimagerotate/php_bug_65070_exp.png \
gdimagerotate/remirh128.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.c b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.c
new file mode 100644
index 00000000000..0bf34a3d78e
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.c
@@ -0,0 +1,35 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/319>
+ *
+ * We're testing that the rotated image actually has the requested background
+ * color.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ FILE *fp;
+ int black;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagerotate", "php_bug_65070.gif");
+ src = gdImageCreateFromGif(fp);
+ fclose(fp);
+
+ black = gdImageColorAllocateAlpha(src, 0, 0, 0, 0);
+ dst = gdImageRotateInterpolated(src, 30.0, black);
+
+ path = gdTestFilePath2("gdimagerotate", "php_bug_65070_exp.png");
+ gdAssertImageEqualsToFile(path, dst);
+ gdFree(path);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.gif b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.gif
new file mode 100644
index 00000000000..4c2fd1b36ea
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070.gif
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070_exp.png
new file mode 100644
index 00000000000..fba85f6f06f
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagerotate/php_bug_65070_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagescale/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagescale/CMakeLists.txt
index 91bd0150176..b1d9cf3d85d 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagescale/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagescale/CMakeLists.txt
@@ -1,4 +1,6 @@
SET(TESTS_FILES
+ bug00329
+ bug00330
github_bug_00218
bug_overflow_large_new_size
)
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagescale/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagescale/Makemodule.am
index 23b89241883..771030151df 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagescale/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagescale/Makemodule.am
@@ -1,5 +1,7 @@
libgd_test_programs += \
+ gdimagescale/bug00329 \
+ gdimagescale/bug00330 \
gdimagescale/github_bug_00218 \
gdimagescale/bug_overflow_large_new_size
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00329.c b/Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00329.c
new file mode 100644
index 00000000000..bc505c12935
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00329.c
@@ -0,0 +1,53 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/329>
+ *
+ * We're testing that for truecolor as well as palette images after
+ * GD_BILINEAR_FIXED scaling the corner pixels of the scaled image have the
+ * expected color.
+ */
+
+
+#include <string.h>
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test(const char *mode)
+{
+ gdImagePtr src, dst;
+ int expected, actual;
+
+ if (strcmp(mode, "palette")) {
+ src = gdImageCreateTrueColor(100, 100);
+ expected = gdTrueColorAlpha(255, 255, 255, gdAlphaOpaque);
+ gdImageFilledRectangle(src, 0,0, 99,99, expected);
+ } else {
+ src = gdImageCreate(100, 100);
+ gdImageColorAllocate(src, 255, 255, 255);
+ expected = gdImageGetTrueColorPixel(src, 49, 49);
+ }
+
+ gdImageSetInterpolationMethod(src, GD_BILINEAR_FIXED);
+ dst = gdImageScale(src, 200, 200);
+
+ actual = gdImageGetPixel(dst, 0, 0);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+ actual = gdImageGetPixel(dst, 0, 199);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+ actual = gdImageGetPixel(dst, 199, 199);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+ actual = gdImageGetPixel(dst, 199, 0);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+}
+
+
+int main()
+{
+ test("palette");
+ test("truecolor");
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00330.c b/Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00330.c
new file mode 100644
index 00000000000..0c9d10c9139
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagescale/bug00330.c
@@ -0,0 +1,32 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/330>.
+ *
+ * We're testing that after scaling a palette image, the center pixel actually
+ * has the expected color value.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ int color;
+
+ src = gdImageCreate(100, 100);
+ gdImageColorAllocate(src, 255, 255, 255);
+
+ gdImageSetInterpolationMethod(src, GD_BILINEAR_FIXED);
+ dst = gdImageScale(src, 200, 200);
+
+ color = gdImageGetPixel(dst, 99, 99);
+ gdTestAssertMsg(color == 0xffffff,
+ "expected color ffffff, but got %x\n", color);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+
+ return 0;
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/CMakeLists.txt
index 31ba4e418b9..f969cdf72d3 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/CMakeLists.txt
@@ -1,4 +1,5 @@
SET(TESTS_FILES
+ alpha_blending
bug00186
gdeffectoverlay
gdeffectmultiply
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/Makemodule.am
index 8722e9afdf0..0a574ad14b1 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/Makemodule.am
@@ -1,7 +1,9 @@
libgd_test_programs += \
+ gdimagesetpixel/alpha_blending \
gdimagesetpixel/bug00186 \
gdimagesetpixel/gdeffectmultiply \
gdimagesetpixel/gdeffectoverlay
EXTRA_DIST += \
- gdimagesetpixel/CMakeLists.txt
+ gdimagesetpixel/CMakeLists.txt \
+ gdimagesetpixel/alphablending_exp.png
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alpha_blending.c b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alpha_blending.c
new file mode 100644
index 00000000000..9874df659d9
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alpha_blending.c
@@ -0,0 +1,54 @@
+/**
+ * Testing all effects
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ int effects[] = {
+ gdEffectReplace, gdEffectAlphaBlend, gdEffectNormal,
+ gdEffectOverlay, gdEffectMultiply
+ };
+ int red[3], blue[3];
+ int x, y, i, j;
+ char *path;
+
+ red[0] = gdTrueColorAlpha(0, 0, 255, 127);
+ red[1] = gdTrueColorAlpha(0, 0, 255, 63);
+ red[2] = gdTrueColorAlpha(0, 0, 255, 0);
+ blue[0] = gdTrueColorAlpha(255, 0, 0, 127);
+ blue[1] = gdTrueColorAlpha(255, 0, 0, 63);
+ blue[2] = gdTrueColorAlpha(255, 0, 0, 0);
+
+ im = gdImageCreateTrueColor(120, 180);
+
+ gdImageAlphaBlending(im, gdEffectReplace);
+ for (j = 0; j < 3; j++) {
+ y = 60 * j;
+ gdImageFilledRectangle(im, 0,y, 119,y+59, red[j]);
+ }
+
+ for (i = 0; i < 5; i++) {
+ x = 20 * i;
+ gdImageAlphaBlending(im, effects[i]);
+ for (j = 0; j < 9; j++) {
+ y = 20 * j;
+ gdImageFilledRectangle(im, x+20,y, x+39,y+19, blue[j % 3]);
+ }
+ }
+
+ gdImageSaveAlpha(im, 1);
+
+ path = gdTestFilePath2("gdimagesetpixel", "alphablending_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alphablending_exp.png b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alphablending_exp.png
new file mode 100644
index 00000000000..39551530452
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagesetpixel/alphablending_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagestringft/gdimagestringft_bbox.c b/Build/source/libs/gd/libgd-src/tests/gdimagestringft/gdimagestringft_bbox.c
index bc2bdd0b791..0161ec8101c 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagestringft/gdimagestringft_bbox.c
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagestringft/gdimagestringft_bbox.c
@@ -73,6 +73,7 @@ int main()
fclose(fp);
done:
gdImageDestroy(im);
+ gdFontCacheShutdown();
free(path);
return error;
}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagestringftex/gdimagestringftex_returnfontpathname.c b/Build/source/libs/gd/libgd-src/tests/gdimagestringftex/gdimagestringftex_returnfontpathname.c
index fc135cd263f..23c094a2f39 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagestringftex/gdimagestringftex_returnfontpathname.c
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagestringftex/gdimagestringftex_returnfontpathname.c
@@ -18,6 +18,7 @@ int main()
return 2;
}
gdFree(strex.fontpath);
+ gdFontCacheShutdown();
free(path);
return 0;
}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/CMakeLists.txt
index 606eb537270..b23d2a1b86a 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/CMakeLists.txt
@@ -1,5 +1,12 @@
SET(TESTS_FILES
+ bug00307
php_bug_72512
)
+IF(JPEG_FOUND)
+LIST(APPEND TESTS_FILES
+ php_bug_67325
+)
+ENDIF(JPEG_FOUND)
+
ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/Makemodule.am
index cd73f092b9b..31f03624f66 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/Makemodule.am
@@ -1,6 +1,13 @@
libgd_test_programs += \
+ gdimagetruecolortopalette/bug00307 \
gdimagetruecolortopalette/php_bug_72512
+if HAVE_LIBJPEG
+libgd_test_programs += \
+ gdimagetruecolortopalette/php_bug_67325
+endif
+
EXTRA_DIST += \
- gdimagetruecolortopalette/CMakeLists.txt
+ gdimagetruecolortopalette/CMakeLists.txt \
+ gdimagetruecolortopalette/php_bug_67325.jpeg
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/bug00307.c b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/bug00307.c
new file mode 100644
index 00000000000..a5c6a04b64f
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/bug00307.c
@@ -0,0 +1,26 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/307>
+ *
+ * We're testing that an image that has been converted to palette with
+ * GD_QUANT_NEUQUANT has its trueColor flag unset.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+
+ im = gdImageCreateTrueColor(100, 100);
+
+ gdTestAssert(gdImageTrueColorToPaletteSetMethod(im, GD_QUANT_NEUQUANT, 0));
+ gdImageTrueColorToPalette(im, 0, 256);
+ gdTestAssert(!gdImageTrueColor(im));
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.c b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.c
new file mode 100644
index 00000000000..29eaf6d8716
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.c
@@ -0,0 +1,38 @@
+/**
+ * Regression test for <https://bugs.php.net/bug.php?id=67325>
+ *
+ * We convert a truecolor image to a palette image and check that no duplicated
+ * white colors are in the resulting palette.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ int i, white;
+
+ fp = gdTestFileOpen2("gdimagetruecolortopalette", "php_bug_67325.jpeg");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromJpeg(fp);
+ gdTestAssert(im != NULL);
+ gdTestAssert(!fclose(fp));
+
+ gdTestAssert(gdImageTrueColorToPalette(im, 0, 256));
+
+ white = 0;
+ for (i = 0; i < im->colorsTotal; i++) {
+ if (im->red[i] == 255 && im->green[i] == 255 && im->blue[i] == 255) {
+ white++;
+ }
+ }
+ gdTestAssertMsg(white <= 1, "At most one white color palette entry expected, got %d\n", white);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.jpeg b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.jpeg
new file mode 100644
index 00000000000..82e8233a761
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_67325.jpeg
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_72512.c b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_72512.c
index d022a94e5e7..3a2158f0ca9 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_72512.c
+++ b/Build/source/libs/gd/libgd-src/tests/gdimagetruecolortopalette/php_bug_72512.c
@@ -12,7 +12,7 @@ int main()
im = gdImageCreateTrueColor(100, 100);
if (im == NULL) {
- gdTestErrorMsg("gdImageCreateTruecolor failed");
+ gdTestErrorMsg("gdImageCreateTruecolor failed\n");
error = 1;
goto exit;
}
diff --git a/Build/source/libs/gd/libgd-src/tests/gdtest/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/gdtest/CMakeLists.txt
index 5f89bc91b75..4b0526252ab 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdtest/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/gdtest/CMakeLists.txt
@@ -1,4 +1,3 @@
-SET(GDTEST_TOP_DIR "${GD_SOURCE_DIR}/tests")
-CONFIGURE_FILE(test_config.h.cmake test_config.h ESCAPE_QUOTES)
+add_definitions(-DGDTEST_TOP_DIR="${CMAKE_CURRENT_SOURCE_DIR}/..")
add_library (gdTest STATIC gdtest.c)
target_link_libraries(gdTest ${GD_LIB})
diff --git a/Build/source/libs/gd/libgd-src/tests/gdtest/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/gdtest/Makemodule.am
index 5b4e39e6e6f..a68842e4925 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdtest/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/gdtest/Makemodule.am
@@ -1,5 +1,4 @@
# Note: Library is declared in tests/Makefile.am as it's used by all the tests.
EXTRA_DIST += \
- gdtest/CMakeLists.txt \
- gdtest/test_config.h.cmake
+ gdtest/CMakeLists.txt
diff --git a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c
index b26d0394a41..b0462fc42d7 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c
+++ b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c
@@ -27,7 +27,6 @@
#include "gd.h"
#include "gdtest.h"
-#include "test_config.h"
/* max is already defined in windows/msvc */
#ifndef max
@@ -47,7 +46,7 @@ gdImagePtr gdTestImageFromPng(const char *filename)
FILE *fp;
/* If the path is relative, then assume it's in the tests/ dir. */
- if (filename[0] == '/'
+ if (filename[0] == '/' || filename[0] == '.'
#ifdef _WIN32
|| filename[1] == ':'
#endif
@@ -590,7 +589,7 @@ int gdTestImageCompareToFile(const char* file, unsigned int line, const char* me
expected = gdTestImageFromPng(expected_file);
if (!expected) {
- _gdTestErrorMsg(file, line, "Cannot open PNG <%s>", expected_file);
+ _gdTestErrorMsg(file, line, "Cannot open PNG <%s>\n", expected_file);
res = 0;
} else {
res = gdTestImageCompareToImage(file, line, message, expected, actual);
diff --git a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h
index fbf37bf4ff6..82d2feba305 100644
--- a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h
+++ b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h
@@ -2,7 +2,6 @@
#define GD_TEST_H
#include <stdarg.h>
-#include "test_config.h"
#define GDTEST_STRING_MAX 1024
typedef struct CuTestImageResult CuTestImageResult;
@@ -72,7 +71,7 @@ int _gdTestErrorMsg(const char* file, unsigned int line, const char* string, ...
#define gdTestAssert(cond) _gdTestAssert(__FILE__, __LINE__, (cond))
-#define gdTestAssertMsg(cond, message, ...) _gdTestAssertMsg(__FILE__, __LINE__, (cond),(message),__VA_ARGS__)
+#define gdTestAssertMsg(cond, message, ...) _gdTestAssertMsg(__FILE__, __LINE__, (cond), (message), ## __VA_ARGS__)
#define gdTestErrorMsg(...) _gdTestErrorMsg(__FILE__, __LINE__, __VA_ARGS__)
diff --git a/Build/source/libs/gd/libgd-src/tests/gdtest/test_config.h.cmake b/Build/source/libs/gd/libgd-src/tests/gdtest/test_config.h.cmake
deleted file mode 100644
index 59d2f0cf7ed..00000000000
--- a/Build/source/libs/gd/libgd-src/tests/gdtest/test_config.h.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Define the full path to the top src dir, required to get the path
- * of each input data */
-#cmakedefine GDTEST_TOP_DIR "@GDTEST_TOP_DIR@"
-
diff --git a/Build/source/libs/gd/libgd-src/tests/gif/bug00006.c b/Build/source/libs/gd/libgd-src/tests/gif/bug00006.c
index f1a7fe86341..c80d3878e5b 100644
--- a/Build/source/libs/gd/libgd-src/tests/gif/bug00006.c
+++ b/Build/source/libs/gd/libgd-src/tests/gif/bug00006.c
@@ -27,6 +27,10 @@ int main()
gdTestErrorMsg("Cannot open <%s> for writing\n", file);
return 1;
}
+
+ gdImageTrueColorToPaletteSetMethod(im, GD_QUANT_JQUANT, 0);
+ gdImageTrueColorToPalette(im, 1, 256);
+
gdImageGif(im,fp);
fclose(fp);
diff --git a/Build/source/libs/gd/libgd-src/tests/test_config.h.in b/Build/source/libs/gd/libgd-src/tests/test_config.h.in
deleted file mode 100644
index f29f20a5d64..00000000000
--- a/Build/source/libs/gd/libgd-src/tests/test_config.h.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef GD_TEST_CONFIG_H
-#define GD_TEST_CONFIG_H
-
-
-/* Define the full path to the top src dir, required to get the path
- * of each input data */
-#define GDTEST_TOP_DIR "@srcdir@"
-#endif
-
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/tga/CMakeLists.txt
index 695a812a401..af234971183 100644
--- a/Build/source/libs/gd/libgd-src/tests/tga/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/tga/CMakeLists.txt
@@ -5,6 +5,8 @@ SET(TESTS_FILES
bug00247a
bug00248
bug00248a
+ heap_overflow
+ tga_read
)
ADD_GD_TESTS()
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/tga/Makemodule.am
index dff828fe395..ab08dbff2b9 100644
--- a/Build/source/libs/gd/libgd-src/tests/tga/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/tga/Makemodule.am
@@ -4,7 +4,9 @@ libgd_test_programs += \
tga/bug00247a \
tga/bug00248 \
tga/bug00248a \
- tga/tga_null
+ tga/heap_overflow \
+ tga/tga_null \
+ tga/tga_read
EXTRA_DIST += \
tga/CMakeLists.txt \
@@ -12,4 +14,9 @@ EXTRA_DIST += \
tga/bug00247.tga \
tga/bug00247a.tga \
tga/bug00248.tga \
- tga/bug00248a.tga
+ tga/bug00248a.tga \
+ tga/heap_overflow_1.tga \
+ tga/heap_overflow_2.tga \
+ tga/tga_read_rgb.png \
+ tga/tga_read_rgb.tga \
+ tga/tga_read_rgb_rle.tga
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow.c b/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow.c
new file mode 100644
index 00000000000..ddd4b63e953
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow.c
@@ -0,0 +1,59 @@
+/**
+ * Test that crafted TGA files don't trigger OOB reads.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void check_file(char *basename);
+static size_t read_test_file(char **buffer, char *basename);
+
+
+int main()
+{
+ check_file("heap_overflow_1.tga");
+ check_file("heap_overflow_2.tga");
+
+ return gdNumFailures();
+}
+
+
+static void check_file(char *basename)
+{
+ gdImagePtr im;
+ char *buffer;
+ size_t size;
+
+ size = read_test_file(&buffer, basename);
+ im = gdImageCreateFromTgaPtr(size, (void *) buffer);
+ gdTestAssert(im == NULL);
+ free(buffer);
+}
+
+
+static size_t read_test_file(char **buffer, char *basename)
+{
+ char *filename;
+ FILE *fp;
+ size_t exp_size, act_size;
+
+ filename = gdTestFilePath2("tga", basename);
+ fp = fopen(filename, "rb");
+ gdTestAssert(fp != NULL);
+
+ fseek(fp, 0, SEEK_END);
+ exp_size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ *buffer = malloc(exp_size);
+ gdTestAssert(*buffer != NULL);
+ act_size = fread(*buffer, sizeof(**buffer), exp_size, fp);
+ gdTestAssert(act_size == exp_size);
+
+ fclose(fp);
+ free(filename);
+
+ return act_size;
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_1.tga b/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_1.tga
new file mode 100644
index 00000000000..e9bc0ecb2a8
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_1.tga
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_2.tga b/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_2.tga
new file mode 100644
index 00000000000..2b681f2df89
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tga/heap_overflow_2.tga
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/tga_read.c b/Build/source/libs/gd/libgd-src/tests/tga/tga_read.c
new file mode 100644
index 00000000000..310b72f4cb6
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tga/tga_read.c
@@ -0,0 +1,40 @@
+/**
+ * Basic test case for reading TGA files.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void assert_equals(char *exp, char *orig);
+
+
+int main()
+{
+ assert_equals("tga_read_rgb.png", "tga_read_rgb.tga");
+ assert_equals("tga_read_rgb.png", "tga_read_rgb_rle.tga");
+
+ return gdNumFailures();
+}
+
+
+static void assert_equals(char *exp, char *orig)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *filename;
+
+ fp = gdTestFileOpen2("tga", orig);
+ gdTestAssertMsg(fp != NULL, "can't open %s", orig);
+
+ im = gdImageCreateFromTga(fp);
+ gdTestAssertMsg(im != NULL, "can't read %s", orig);
+ fclose(fp);
+
+ filename = gdTestFilePath2("tga", exp);
+ gdAssertImageEqualsToFile(filename, im);
+ gdFree(filename);
+
+ gdImageDestroy(im);
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.png b/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.png
new file mode 100644
index 00000000000..bc468e3d927
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.tga b/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.tga
new file mode 100644
index 00000000000..5f11f5a080f
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb.tga
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb_rle.tga b/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb_rle.tga
new file mode 100644
index 00000000000..ce845ad0c3d
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tga/tga_read_rgb_rle.tga
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/tiff/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/tiff/CMakeLists.txt
index 1f4f4c06f28..e5862ac126f 100644
--- a/Build/source/libs/gd/libgd-src/tests/tiff/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/tiff/CMakeLists.txt
@@ -1,6 +1,7 @@
IF(TIFF_FOUND)
SET(TESTS_FILES
tiff_im2im
+ tiff_invalid_read
tiff_null
tiff_dpi
)
diff --git a/Build/source/libs/gd/libgd-src/tests/tiff/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/tiff/Makemodule.am
index fd396990973..670434a7d32 100644
--- a/Build/source/libs/gd/libgd-src/tests/tiff/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/tiff/Makemodule.am
@@ -2,8 +2,12 @@ if HAVE_LIBTIFF
libgd_test_programs += \
tiff/tiff_dpi \
tiff/tiff_im2im \
+ tiff/tiff_invalid_read \
tiff/tiff_null
endif
EXTRA_DIST += \
- tiff/CMakeLists.txt
+ tiff/CMakeLists.txt \
+ tiff/tiff_invalid_read_1.tiff \
+ tiff/tiff_invalid_read_2.tiff \
+ tiff/tiff_invalid_read_3.tiff
diff --git a/Build/source/libs/gd/libgd-src/tests/tiff/tiff_dpi.c b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_dpi.c
index 347abf179a9..d639839c420 100644
--- a/Build/source/libs/gd/libgd-src/tests/tiff/tiff_dpi.c
+++ b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_dpi.c
@@ -66,12 +66,12 @@ int main()
if (dst->res_x != res_x) {
status = 1;
- gdTestErrorMsg("mismatch in res_x (got %d, expected %d)", dst->res_x, res_x);
+ gdTestErrorMsg("mismatch in res_x (got %d, expected %d)\n", dst->res_x, res_x);
}
if (dst->res_y != res_y) {
status = 1;
- gdTestErrorMsg("mismatch in res_y (got %d, expected %d)", dst->res_y, res_y);
+ gdTestErrorMsg("mismatch in res_y (got %d, expected %d)\n", dst->res_y, res_y);
}
gdImageDestroy(dst);
@@ -81,4 +81,4 @@ door0:
gdImageDestroy(src);
return status;
}
-#endif \ No newline at end of file
+#endif
diff --git a/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read.c b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read.c
new file mode 100644
index 00000000000..bed538914b6
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read.c
@@ -0,0 +1,61 @@
+/*
+We're testing that reading corrupt TIFF files doesn't cause any memory issues,
+and that the operation gracefully fails (i.e. gdImageCreateFromTiffPtr() returns
+NULL).
+*/
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void check_file(char *basename);
+static size_t read_test_file(char **buffer, char *basename);
+
+
+int main()
+{
+ check_file("tiff_invalid_read_1.tiff");
+ check_file("tiff_invalid_read_2.tiff");
+ check_file("tiff_invalid_read_3.tiff");
+
+ return gdNumFailures();
+}
+
+
+static void check_file(char *basename)
+{
+ gdImagePtr im;
+ char *buffer;
+ size_t size;
+
+ size = read_test_file(&buffer, basename);
+ im = gdImageCreateFromTiffPtr(size, (void *) buffer);
+ gdTestAssert(im == NULL);
+ free(buffer);
+}
+
+
+static size_t read_test_file(char **buffer, char *basename)
+{
+ char *filename;
+ FILE *fp;
+ size_t exp_size, act_size;
+
+ filename = gdTestFilePath2("tiff", basename);
+ fp = fopen(filename, "rb");
+ gdTestAssert(fp != NULL);
+
+ fseek(fp, 0, SEEK_END);
+ exp_size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ *buffer = malloc(exp_size);
+ gdTestAssert(*buffer != NULL);
+ act_size = fread(*buffer, sizeof(**buffer), exp_size, fp);
+ gdTestAssert(act_size == exp_size);
+
+ fclose(fp);
+ free(filename);
+
+ return act_size;
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_1.tiff b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_1.tiff
new file mode 100644
index 00000000000..b3877e337b3
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_1.tiff
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_2.tiff b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_2.tiff
new file mode 100644
index 00000000000..f9967e54217
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_2.tiff
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_3.tiff b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_3.tiff
new file mode 100644
index 00000000000..67ca2a7c6e1
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/tiff/tiff_invalid_read_3.tiff
Binary files differ
diff --git a/Build/source/libs/gd/libgd-src/tests/webp/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/webp/CMakeLists.txt
index 32e2c1d8347..d2db95b9698 100644
--- a/Build/source/libs/gd/libgd-src/tests/webp/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/tests/webp/CMakeLists.txt
@@ -1,6 +1,7 @@
IF(WEBP_FOUND)
SET(TESTS_FILES
bug00111
+ bug_double_free
)
ENDIF(WEBP_FOUND)
diff --git a/Build/source/libs/gd/libgd-src/tests/webp/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/webp/Makemodule.am
index b03db6e239e..f01f9e672fc 100644
--- a/Build/source/libs/gd/libgd-src/tests/webp/Makemodule.am
+++ b/Build/source/libs/gd/libgd-src/tests/webp/Makemodule.am
@@ -1,7 +1,9 @@
if HAVE_LIBWEBP
libgd_test_programs += \
- webp/bug00111
+ webp/bug00111 \
+ webp/bug_double_free
endif
EXTRA_DIST += \
- webp/CMakeLists.txt
+ webp/CMakeLists.txt \
+ webp/bug_double_free.jpg
diff --git a/Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.c b/Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.c
new file mode 100644
index 00000000000..43eececfc19
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.c
@@ -0,0 +1,29 @@
+/**
+ * Test that a too large image doesn't trigger an double-free when written
+ * to memory.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im1, im2;
+ FILE *fp;
+ int size;
+
+ fp = gdTestFileOpen2("webp", "bug_double_free.jpg");
+ gdTestAssert(fp != NULL);
+ im1 = gdImageCreateFromJpeg(fp);
+ gdTestAssert(im1 != NULL);
+ fclose(fp);
+
+ im2 = gdImageWebpPtr(im1, &size);
+ gdTestAssert(im2 == NULL);
+
+ gdImageDestroy(im1);
+
+ return gdNumFailures();
+}
diff --git a/Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.jpg b/Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.jpg
new file mode 100644
index 00000000000..9b792fb4a7d
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/webp/bug_double_free.jpg
Binary files differ