File netpbm-10.26.44-aliasing.patch of Package netpbm
--- lib/util/mallocvar.h
+++ lib/util/mallocvar.h
@@ -12,9 +12,8 @@
#include <limits.h>
#include <stdlib.h>
-static __inline__ void
-mallocProduct(void ** const resultP,
- unsigned int const factor1,
+static __inline__ void *
+mallocProduct(unsigned int const factor1,
unsigned int const factor2) {
/*----------------------------------------------------------------------------
malloc a space whose size in bytes is the product of 'factor1' and
@@ -30,9 +29,9 @@
nobody really needs to allocate more than 4GB of memory.
-----------------------------------------------------------------------------*/
if (UINT_MAX / factor2 < factor1)
- *resultP = NULL; \
+ return NULL;
else
- *resultP = malloc(factor1 * factor2);
+ return malloc(factor1 * factor2);
}
@@ -51,7 +50,7 @@
#define MALLOCARRAY(arrayName, nElements) \
- mallocProduct((void **)(void *)&arrayName, nElements, sizeof(arrayName[0]))
+ (arrayName = mallocProduct(nElements, sizeof(arrayName[0])))
#define REALLOCARRAY(arrayName, nElements) \
reallocProduct((void **)&arrayName, nElements, sizeof(arrayName[0]))