Fix fatal crash on 64 bit Linux 687/head
authorStefan Weil <sw@weilnetz.de>
Wed, 6 Jan 2016 20:34:59 +0000 (21:34 +0100)
committerStefan Weil <sw@weilnetz.de>
Wed, 6 Jan 2016 20:40:09 +0000 (21:40 +0100)
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 <sw@weilnetz.de>
src/lib/openjp2/opj_malloc.c

index e91b660e9a0a8acabc48b3dfcef535ef454d4e95..e04db912b88b941f1d701283916e278a94e1ce71 100644 (file)
 #define OPJ_SKIP_POISON
 #include "opj_includes.h"
 
+#if defined(OPJ_HAVE_MALLOC_H) && defined(OPJ_HAVE_MEMALIGN)
+# include <malloc.h>
+#endif
+
 #ifndef SIZE_MAX
 # define SIZE_MAX ((size_t) -1)
 #endif