summary refs log tree commit diff
path: root/gnu/packages/patches/giflib-make-reallocarray-private.patch
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-03-20 14:13:05 +0100
committerMarius Bakke <mbakke@fastmail.com>2018-03-20 14:13:05 +0100
commitdc7e07c9b9780883a462c5973cd2ecad06fdb4ae (patch)
tree14d185abfdd092a470e72ea27a3dad879145fb76 /gnu/packages/patches/giflib-make-reallocarray-private.patch
parent616446ffbf9af9e8e5df0ef40c4e33dba9e25152 (diff)
parentdbc75dadb54dd0e6b3a125949c26aadfa3bff4ca (diff)
downloadguix-dc7e07c9b9780883a462c5973cd2ecad06fdb4ae.tar.gz
Merge branch 'staging'
Diffstat (limited to 'gnu/packages/patches/giflib-make-reallocarray-private.patch')
-rw-r--r--gnu/packages/patches/giflib-make-reallocarray-private.patch120
1 files changed, 120 insertions, 0 deletions
diff --git a/gnu/packages/patches/giflib-make-reallocarray-private.patch b/gnu/packages/patches/giflib-make-reallocarray-private.patch
new file mode 100644
index 0000000000..69228c5be8
--- /dev/null
+++ b/gnu/packages/patches/giflib-make-reallocarray-private.patch
@@ -0,0 +1,120 @@
+Move the declaration from gif_lib.h to gif_lib_private.h to solve
+conflicts when some .c-file #includes both stdlib.h and gif_lib.h.
+See also https://sourceforge.net/p/giflib/bugs/110/
+
+diff -ur giflib-5.1.4.orig/lib/dgif_lib.c giflib-5.1.4/lib/dgif_lib.c
+--- giflib-5.1.4.orig/lib/dgif_lib.c	2018-02-28 20:31:02.294682673 +0100
++++ giflib-5.1.4/lib/dgif_lib.c	2018-02-28 22:38:11.659126414 +0100
+@@ -396,7 +396,7 @@
+ 
+     if (GifFile->SavedImages) {
+         SavedImage* new_saved_images =
+-            (SavedImage *)reallocarray(GifFile->SavedImages,
++            (SavedImage *)giflib_private_reallocarray(GifFile->SavedImages,
+                             (GifFile->ImageCount + 1), sizeof(SavedImage));
+         if (new_saved_images == NULL) {
+             GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
+@@ -1108,7 +1108,7 @@
+               if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
+                   return GIF_ERROR;
+               }
+-              sp->RasterBits = (unsigned char *)reallocarray(NULL, ImageSize,
++              sp->RasterBits = (unsigned char *)giflib_private_reallocarray(NULL, ImageSize,
+                       sizeof(GifPixelType));
+ 
+               if (sp->RasterBits == NULL) {
+diff -ur giflib-5.1.4.orig/lib/gifalloc.c giflib-5.1.4/lib/gifalloc.c
+--- giflib-5.1.4.orig/lib/gifalloc.c	2018-02-28 20:31:02.294682673 +0100
++++ giflib-5.1.4/lib/gifalloc.c	2018-02-28 22:38:11.657126423 +0100
+@@ -8,7 +8,7 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
+-#include "gif_lib.h"
++#include "gif_lib_private.h"
+ 
+ #define MAX(x, y)    (((x) > (y)) ? (x) : (y))
+ 
+@@ -188,7 +188,7 @@
+ 
+         /* perhaps we can shrink the map? */
+         if (RoundUpTo < ColorUnion->ColorCount) {
+-            GifColorType *new_map = (GifColorType *)reallocarray(Map,
++            GifColorType *new_map = (GifColorType *)giflib_private_reallocarray(Map,
+                                  RoundUpTo, sizeof(GifColorType));
+             if( new_map == NULL ) {
+                 GifFreeMapObject(ColorUnion);
+@@ -232,7 +232,7 @@
+     if (*ExtensionBlocks == NULL)
+         *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock));
+     else {
+-        ExtensionBlock* ep_new = (ExtensionBlock *)reallocarray
++        ExtensionBlock* ep_new = (ExtensionBlock *)giflib_private_reallocarray
+ 				 (*ExtensionBlocks, (*ExtensionBlockCount + 1),
+                                       sizeof(ExtensionBlock));
+         if( ep_new == NULL )
+@@ -325,7 +325,7 @@
+     if (GifFile->SavedImages == NULL)
+         GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
+     else
+-        GifFile->SavedImages = (SavedImage *)reallocarray(GifFile->SavedImages,
++        GifFile->SavedImages = (SavedImage *)giflib_private_reallocarray(GifFile->SavedImages,
+                                (GifFile->ImageCount + 1), sizeof(SavedImage));
+ 
+     if (GifFile->SavedImages == NULL)
+@@ -355,7 +355,7 @@
+             }
+ 
+             /* next, the raster */
+-            sp->RasterBits = (unsigned char *)reallocarray(NULL,
++            sp->RasterBits = (unsigned char *)giflib_private_reallocarray(NULL,
+                                                   (CopyFrom->ImageDesc.Height *
+                                                   CopyFrom->ImageDesc.Width),
+ 						  sizeof(GifPixelType));
+@@ -369,7 +369,7 @@
+ 
+             /* finally, the extension blocks */
+             if (sp->ExtensionBlocks != NULL) {
+-                sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL,
++                sp->ExtensionBlocks = (ExtensionBlock *)giflib_private_reallocarray(NULL,
+                                       CopyFrom->ExtensionBlockCount,
+ 				      sizeof(ExtensionBlock));
+                 if (sp->ExtensionBlocks == NULL) {
+diff -ur giflib-5.1.4.orig/lib/gif_lib.h giflib-5.1.4/lib/gif_lib.h
+--- giflib-5.1.4.orig/lib/gif_lib.h	2018-02-28 20:31:02.294682673 +0100
++++ giflib-5.1.4/lib/gif_lib.h	2018-02-28 20:31:43.135716712 +0100
+@@ -244,9 +244,6 @@
+                                      GifPixelType ColorTransIn2[]);
+ extern int GifBitSize(int n);
+ 
+-extern void *
+-reallocarray(void *optr, size_t nmemb, size_t size);
+-
+ /******************************************************************************
+  Support for the in-core structures allocation (slurp mode).              
+ ******************************************************************************/
+diff -ur giflib-5.1.4.orig/lib/gif_lib_private.h giflib-5.1.4/lib/gif_lib_private.h
+--- giflib-5.1.4.orig/lib/gif_lib_private.h	2018-02-28 20:31:02.294682673 +0100
++++ giflib-5.1.4/lib/gif_lib_private.h	2018-02-28 22:38:11.657126423 +0100
+@@ -54,6 +54,9 @@
+     bool gif89;
+ } GifFilePrivateType;
+ 
++extern void *
++giflib_private_reallocarray(void *optr, size_t nmemb, size_t size);
++
+ #endif /* _GIF_LIB_PRIVATE_H */
+ 
+ /* end */
+diff -ur giflib-5.1.4.orig/lib/openbsd-reallocarray.c giflib-5.1.4/lib/openbsd-reallocarray.c
+--- giflib-5.1.4.orig/lib/openbsd-reallocarray.c	2018-02-28 20:31:02.295682659 +0100
++++ giflib-5.1.4/lib/openbsd-reallocarray.c	2018-02-28 22:38:11.656126428 +0100
+@@ -27,7 +27,7 @@
+ #define MUL_NO_OVERFLOW	((size_t)1 << (sizeof(size_t) * 4))
+ 
+ void *
+-reallocarray(void *optr, size_t nmemb, size_t size)
++giflib_private_reallocarray(void *optr, size_t nmemb, size_t size)
+ {
+ 	if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ 	    nmemb > 0 && SIZE_MAX / nmemb < size) {