]> git.imager.perl.org - imager.git/commitdiff
check for the uninitialized gif89 bug in 4.2.0 and probe for the 5.0.1 api
authorTony Cook <tony@develop-help.com>
Fri, 12 Oct 2012 09:42:25 +0000 (20:42 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 12 Oct 2012 09:42:25 +0000 (20:42 +1100)
Changes
GIF/Changes
GIF/Makefile.PL

diff --git a/Changes b/Changes
index da056237668dedbe9855c959b6dec37e002a66bf..73f06f1e1cff3f53caf1b5743ac7772d6267ead3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -9,6 +9,12 @@ Imager release history.  Older releases can be found in Changes.old
    always use a GIF89a header even if none of the images were
    transparent.
 
+ - update the GIF library probe code to check for the new giflib 5.0.1
+   EGifSetGifVersion() function, and to check for the giflib 4.2.0
+   uninitialized gif89 bug.
+   https://rt.cpan.org/Ticket/Display.html?id=79679
+   http://sourceforge.net/tracker/?func=detail&aid=3574283&group_id=102202&atid=631304
+
  - previously the probe step for freetype-config would fail on cygwin
 
  - avoid static variables when capturing IPTC data from JPEG files
index 20ccb48f0edf415dd3fa1e546f112e7d62ccc2d6..6d0a2dc426716db17b44da3c2b269be12b840fe3 100644 (file)
@@ -9,6 +9,12 @@ Imager-File-GIF 0.85
  - previously a transparency enabled write (the default) would always
    use a GIF89a header even if none of the images were transparent.
 
+ - update the GIF library probe code to check for the new giflib 5.0.1
+   EGifSetGifVersion() function, and to check for the giflib 4.2.0
+   uninitialized gif89 bug.
+   https://rt.cpan.org/Ticket/Display.html?id=79679
+   http://sourceforge.net/tracker/?func=detail&aid=3574283&group_id=102202&atid=631304
+
 Imager-File-GIF 0.84 - released with Imager 0.92_01
 ====================
 
index 378dd435eef6db190b527b30062bd5b207321dff..5580ed18970a2032ec371d75933586a656a4e9ea 100644 (file)
@@ -74,7 +74,7 @@ my %probe =
    inccheck => sub { -e File::Spec->catfile($_[0], "gif_lib.h") },
    libbase => "gif",
    testcode => _gif_test_code(),
-   testcodeheaders => [ "stddef.h", "gif_lib.h", "stdio.h" ],
+   testcodeheaders => [ "stddef.h", "gif_lib.h", "stdio.h", "errno.h", "string.h" ],
    incpath => \@incpaths,
    libpath => \@libpaths,
   );
@@ -121,6 +121,11 @@ int ver_maj = GIFLIB_MAJOR;
 int ver_min = GIFLIB_MINOR;
 int error;
 #endif
+GifColorType colors[2];
+ColorMapObject *map;
+FILE *fh;
+char buf[6];
+int mode;
 #if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
 gf=DGifOpenFileName("testimg/expected.gif", &error);
 #else
@@ -172,6 +177,52 @@ if (ver_maj == 4 && ver_min < 1) {
   fprintf(stderr, "GIF: you need at least giflib 4.1\n");
   return 1;
 }
+
+/* test we write both GIF87a and GIF89a files */
+for (mode = 0; mode < 2; ++mode) {
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+  gf=EGifOpenFileName("probe.gif", 0, &error);
+  EGifSetGifVersion(gf, mode);
+
+#else
+  gf=EGifOpenFileName("probe.gif", 0);
+  EGifSetGifVersion(mode ? "89a" : "87a");
+#endif
+  if (!gf) {
+    fprintf(stderr, "GIF: cannot create probe.gif for testing\n");
+    return 1;
+  }
+  colors[0].Red = colors[0].Green = colors[0].Blue = 0;
+  colors[1].Red = colors[1].Green = colors[1].Blue = 0;
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+  map = GifMakeMapObject(2, colors);
+#else
+  map = MakeMapObject(2, colors);
+#endif
+  EGifPutScreenDesc(gf, 1, 1, 1, 0, map);
+  EGifPutImageDesc(gf, 0, 0, 1, 1, 0, NULL);
+  EGifPutPixel(gf, 0);
+  EGifCloseFile(gf);
+
+  fh = fopen("probe.gif", "r");
+  if (!fh) {
+    fprintf(stderr, "GIF: cannot open probe.gif for reading\n");
+    return 1;
+  }
+  errno = 0;
+  memset(buf, 0, sizeof(buf));
+  if (fread(buf, 1, 6, fh) != 6) {
+    fprintf(stderr, "GIF: cannot read probe.gif header (%d)\n", errno);
+    return 1;
+  }
+  fclose(fh);
+  if (memcmp(buf, mode ? "GIF89a" : "GIF87a", 6)) {
+    fprintf(stderr, "GIF: incorrect header on test - 4.2.0 bug? (mode %d, buf %-6s)\n", mode, buf);
+    return 1;
+  }
+  remove("probe.gif");
+}
+
 fprintf(stderr, "GIF: Major %d, Minor %d\n", ver_maj, ver_min);
 return 0;
 CODE