summaryrefslogtreecommitdiff
path: root/tests/gdimagepolygon
diff options
context:
space:
mode:
authortabe <none@none>2010-01-14 19:10:57 +0900
committertabe <none@none>2010-01-14 19:10:57 +0900
commit5876dc8ef4a4dedcc2009e2df7cf68b2d1216cb1 (patch)
treee22d60e7872f6399f65f16f394510d640e4e7864 /tests/gdimagepolygon
parent1ad34e9c8c7d3e7ee82519a0ea73cf0fd4200a52 (diff)
downloadlibgd-5876dc8ef4a4dedcc2009e2df7cf68b2d1216cb1.tar.gz
fix possible SEGV by negatiev num of points
Diffstat (limited to 'tests/gdimagepolygon')
-rw-r--r--tests/gdimagepolygon/CMakeLists.txt13
-rw-r--r--tests/gdimagepolygon/Makefile.am11
-rw-r--r--tests/gdimagepolygon/gdimagepolygon0.c22
-rw-r--r--tests/gdimagepolygon/gdimagepolygon0.pngbin0 -> 95 bytes
-rw-r--r--tests/gdimagepolygon/gdimagepolygon1.c30
-rw-r--r--tests/gdimagepolygon/gdimagepolygon1.pngbin0 -> 99 bytes
-rw-r--r--tests/gdimagepolygon/gdimagepolygon2.c32
-rw-r--r--tests/gdimagepolygon/gdimagepolygon2.pngbin0 -> 140 bytes
-rw-r--r--tests/gdimagepolygon/gdimagepolygon3.c34
-rw-r--r--tests/gdimagepolygon/gdimagepolygon3.pngbin0 -> 271 bytes
10 files changed, 142 insertions, 0 deletions
diff --git a/tests/gdimagepolygon/CMakeLists.txt b/tests/gdimagepolygon/CMakeLists.txt
new file mode 100644
index 0000000..ae8d8dd
--- /dev/null
+++ b/tests/gdimagepolygon/CMakeLists.txt
@@ -0,0 +1,13 @@
+SET(TESTS_FILES
+ gdimagepolygon0
+ gdimagepolygon1
+ gdimagepolygon2
+ gdimagepolygon3
+)
+
+FOREACH(test_name ${TESTS_FILES})
+ add_executable(${test_name} "${test_name}.c")
+ target_link_libraries (${test_name} ${GDTESTS_TARGET_LINK})
+ get_target_property(test_path ${test_name} LOCATION)
+ ADD_TEST(${test_name} ${test_path})
+ENDFOREACH(test_name)
diff --git a/tests/gdimagepolygon/Makefile.am b/tests/gdimagepolygon/Makefile.am
new file mode 100644
index 0000000..0ae2c29
--- /dev/null
+++ b/tests/gdimagepolygon/Makefile.am
@@ -0,0 +1,11 @@
+## Process this file with automake to produce Makefile.in -*-Makefile-*-
+
+EXTRA_DIST = CMakeLists.txt \
+ gdimagepolygon0.c \
+ gdimagepolygon0.png \
+ gdimagepolygon1.c \
+ gdimagepolygon1.png \
+ gdimagepolygon2.c \
+ gdimagepolygon2.png \
+ gdimagepolygon3.c \
+ gdimagepolygon3.png
diff --git a/tests/gdimagepolygon/gdimagepolygon0.c b/tests/gdimagepolygon/gdimagepolygon0.c
new file mode 100644
index 0000000..20fa423
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon0.c
@@ -0,0 +1,22 @@
+#include <stdlib.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int
+main(void)
+{
+ gdImagePtr im;
+ int white, black, r;
+
+ im = gdImageCreate(100, 100);
+ if (!im) exit(EXIT_FAILURE);
+ white = gdImageColorAllocate(im, 0xff, 0xff, 0xff);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageFilledRectangle(im, 0, 0, 99, 99, white);
+ gdImagePolygon(im, NULL, 0, black); /* no effect */
+ gdImagePolygon(im, NULL, -1, black); /* no effect */
+ r = gdAssertImageEqualsToFile(GDTEST_TOP_DIR "/gdimagepolygon/gdimagepolygon0.png", im);
+ gdImageDestroy(im);
+ if (!r) exit(EXIT_FAILURE);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/gdimagepolygon/gdimagepolygon0.png b/tests/gdimagepolygon/gdimagepolygon0.png
new file mode 100644
index 0000000..14c7090
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon0.png
Binary files differ
diff --git a/tests/gdimagepolygon/gdimagepolygon1.c b/tests/gdimagepolygon/gdimagepolygon1.c
new file mode 100644
index 0000000..b0949d4
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon1.c
@@ -0,0 +1,30 @@
+#include <stdlib.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int
+main(void)
+{
+ gdImagePtr im;
+ int white, black, r;
+ gdPointPtr points;
+
+ im = gdImageCreate(100, 100);
+ if (!im) exit(EXIT_FAILURE);
+ white = gdImageColorAllocate(im, 0xff, 0xff, 0xff);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageFilledRectangle(im, 0, 0, 99, 99, white);
+ points = (gdPointPtr)gdCalloc(3, sizeof(gdPoint));
+ if (!points) {
+ gdImageDestroy(im);
+ exit(EXIT_FAILURE);
+ }
+ points[0].x = 10;
+ points[0].y = 10;
+ gdImagePolygon(im, points, 1, black);
+ r = gdAssertImageEqualsToFile(GDTEST_TOP_DIR "/gdimagepolygon/gdimagepolygon1.png", im);
+ gdFree(points);
+ gdImageDestroy(im);
+ if (!r) exit(EXIT_FAILURE);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/gdimagepolygon/gdimagepolygon1.png b/tests/gdimagepolygon/gdimagepolygon1.png
new file mode 100644
index 0000000..845c5f6
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon1.png
Binary files differ
diff --git a/tests/gdimagepolygon/gdimagepolygon2.c b/tests/gdimagepolygon/gdimagepolygon2.c
new file mode 100644
index 0000000..79e9420
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon2.c
@@ -0,0 +1,32 @@
+#include <stdlib.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int
+main(void)
+{
+ gdImagePtr im;
+ int white, black, r;
+ gdPointPtr points;
+
+ im = gdImageCreate(100, 100);
+ if (!im) exit(EXIT_FAILURE);
+ white = gdImageColorAllocate(im, 0xff, 0xff, 0xff);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageFilledRectangle(im, 0, 0, 99, 99, white);
+ points = (gdPointPtr)gdCalloc(3, sizeof(gdPoint));
+ if (!points) {
+ gdImageDestroy(im);
+ exit(EXIT_FAILURE);
+ }
+ points[0].x = 10;
+ points[0].y = 10;
+ points[1].x = 50;
+ points[1].y = 70;
+ gdImagePolygon(im, points, 2, black);
+ r = gdAssertImageEqualsToFile(GDTEST_TOP_DIR "/gdimagepolygon/gdimagepolygon2.png", im);
+ gdFree(points);
+ gdImageDestroy(im);
+ if (!r) exit(EXIT_FAILURE);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/gdimagepolygon/gdimagepolygon2.png b/tests/gdimagepolygon/gdimagepolygon2.png
new file mode 100644
index 0000000..80f91a2
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon2.png
Binary files differ
diff --git a/tests/gdimagepolygon/gdimagepolygon3.c b/tests/gdimagepolygon/gdimagepolygon3.c
new file mode 100644
index 0000000..7701c51
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon3.c
@@ -0,0 +1,34 @@
+#include <stdlib.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int
+main(void)
+{
+ gdImagePtr im;
+ int white, black, r;
+ gdPointPtr points;
+
+ im = gdImageCreate(100, 100);
+ if (!im) exit(EXIT_FAILURE);
+ white = gdImageColorAllocate(im, 0xff, 0xff, 0xff);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageFilledRectangle(im, 0, 0, 99, 99, white);
+ points = (gdPointPtr)gdCalloc(3, sizeof(gdPoint));
+ if (!points) {
+ gdImageDestroy(im);
+ exit(EXIT_FAILURE);
+ }
+ points[0].x = 10;
+ points[0].y = 10;
+ points[1].x = 50;
+ points[1].y = 70;
+ points[2].x = 90;
+ points[2].y = 30;
+ gdImagePolygon(im, points, 3, black);
+ r = gdAssertImageEqualsToFile(GDTEST_TOP_DIR "/gdimagepolygon/gdimagepolygon3.png", im);
+ gdFree(points);
+ gdImageDestroy(im);
+ if (!r) exit(EXIT_FAILURE);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/gdimagepolygon/gdimagepolygon3.png b/tests/gdimagepolygon/gdimagepolygon3.png
new file mode 100644
index 0000000..aaff882
--- /dev/null
+++ b/tests/gdimagepolygon/gdimagepolygon3.png
Binary files differ