summaryrefslogtreecommitdiff
path: root/graphics/gif2png/patches/patch-aa
blob: d05030a3c4dd3f57317cac1228bd823c85acbb20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$NetBSD: patch-aa,v 1.6 2012/03/07 15:28:12 wiz Exp $

Fix build with png-1.5.

--- gif2png.c.orig	2012-01-28 23:02:06.000000000 +0000
+++ gif2png.c
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>	/* for isatty() */
+#include <zlib.h>
 #include <sys/stat.h>
 #include <utime.h>
 
@@ -122,8 +123,8 @@ int writefile(struct GIFelement *s,struc
     int colors_used = 0;
     byte remap[MAXCMSIZE];
     int low_prec;
-    png_struct *png_ptr = xalloc(sizeof (png_struct));
-    png_info *info_ptr = xalloc(sizeof (png_info));
+    png_struct *png_ptr;
+    png_info *info_ptr;
     int p;
     int gray_bitdepth;
     png_color pal_rgb[MAXCMSIZE], *pltep;
@@ -138,6 +139,19 @@ int writefile(struct GIFelement *s,struc
     png_text software;
     png_text comment;
 
+    png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+    if (png_ptr == NULL) {
+      fprintf(stderr, "gif2png: fatal error, out of memory\n");
+      fprintf(stderr, "gif2png: exiting ungracefully\n");
+      exit(1);
+    }
+    info_ptr = png_create_info_struct(png_ptr);
+    if (info_ptr == NULL) {
+      fprintf(stderr, "gif2png: fatal error, out of memory\n");
+      fprintf(stderr, "gif2png: exiting ungracefully\n");
+      exit(1);
+    }
+
     /* these volatile declarations prevent gcc warnings ("variable might be
      *  clobbered by `longjmp' or `vfork'") */
     volatile int gray = TRUE;