From 9cad6bc1f68be54189c6db8a7fcef6f994daf891 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 6 Jan 2016 21:34:59 +0100 Subject: [PATCH] Fix fatal crash on 64 bit Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, OpenJPEG uses the function memalign to allocate aligned memory on Linux systems. That function needs malloc.h which was missing. This results in a compiler warning: openjpeg/src/lib/openjp2/opj_malloc.c:63:3: warning: implicit declaration of function ‘memalign’ [-Wimplicit-function-declaration] On hosts where sizeof(int) < sizeof(void *) the return value of memalign will be truncated which results in an invalid pointer. That caused "make test" to produce lots of segmentation faults when running on a 64 bit Linux host. Signed-off-by: Stefan Weil --- src/lib/openjp2/opj_malloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/openjp2/opj_malloc.c b/src/lib/openjp2/opj_malloc.c index e91b660e..e04db912 100644 --- a/src/lib/openjp2/opj_malloc.c +++ b/src/lib/openjp2/opj_malloc.c @@ -32,6 +32,10 @@ #define OPJ_SKIP_POISON #include "opj_includes.h" +#if defined(OPJ_HAVE_MALLOC_H) && defined(OPJ_HAVE_MEMALIGN) +# include +#endif + #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif