Avoid pointer arithmetic with (void *) pointers. 644/head
authorStephan Mühlstrasser <stm@pdflib.com>
Wed, 21 Oct 2015 07:01:31 +0000 (09:01 +0200)
committerStephan Mühlstrasser <stm@pdflib.com>
Wed, 21 Oct 2015 07:01:31 +0000 (09:01 +0200)
src/lib/openjp2/opj_malloc.c

index 04ef055c9434aae571ca9c16eee4c91295fac016..a4aea30f252a759a52030210c3e311965f4a3598 100644 (file)
@@ -166,7 +166,7 @@ static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment, size_t ne
       size_t new_offset;
 
       /* realloc created a new copy, realign the copied memory block */
-      old_offset = (size_t)(ptr - oldmem);
+      old_offset = (size_t)((OPJ_UINT8*)ptr - (OPJ_UINT8*)oldmem);
 
       /* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
       /* Use the fact that alignment + 1U is a power of 2 */