summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/tests/gif/bug00499.c
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
committerKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
commitad547a6b5986815fda458221149728d9d9ab1d87 (patch)
tree16296910eb3eca724371474ea9aea3994dc69614 /Build/source/libs/gd/libgd-src/tests/gif/bug00499.c
parent947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff)
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/tests/gif/bug00499.c')
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gif/bug00499.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-src/tests/gif/bug00499.c b/Build/source/libs/gd/libgd-src/tests/gif/bug00499.c
new file mode 100644
index 00000000000..0fedb927ca4
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/tests/gif/bug00499.c
@@ -0,0 +1,51 @@
+/**
+ * Test that adding identical images to GIF animations do no double-free
+ *
+ * We are adding two frames to a GIF animation in gdDisposalNone mode, were the
+ * second frame is identical to the first, which result in that image to have
+ * zero extent. This program must not cause any memory issues.
+ *
+ * See also <https://github.com/libgd/libgd/issues/499>.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ int black;
+ int size;
+ void * res;
+
+ im = gdImageCreate(100, 100);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageRectangle(im, 0, 0, 10, 10, black);
+
+ res = gdImageGifAnimBeginPtr(im, &size, 1, 3);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ res = gdImageGifAnimAddPtr(im, &size, 0, 0, 0, 100, gdDisposalNone, NULL);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ res = gdImageGifAnimAddPtr(im, &size, 0, 0, 0, 100, gdDisposalNone, im);
+ gdTestAssert(res == NULL);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ res = gdImageGifAnimEndPtr(&size);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}