From: Masashi Honma Date: Thu, 26 Aug 2010 15:35:55 +0000 (+0300) Subject: trace: Fix void pointer arithmetic X-Git-Tag: hostap-1-bp~1219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c77ad1889664f85f03ea13b629f3107189fe0cc;p=thirdparty%2Fhostap.git trace: Fix void pointer arithmetic The arithmetic on void pointer exists in trace routine. On GNU C, it works because void pointer size is 1, but not all compilers behave like this. So this patch specifies the size of the pointer. --- diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index cb23f7207..6f58fa46c 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -370,7 +370,7 @@ void * os_realloc(void *ptr, size_t size) if (ptr == NULL) return os_malloc(size); - a = ptr - sizeof(*a); + a = (struct os_alloc_trace *) ptr - 1; if (a->magic != ALLOC_MAGIC) { wpa_printf(MSG_INFO, "REALLOC[%p]: invalid magic 0x%x%s", a, a->magic, @@ -396,7 +396,7 @@ void os_free(void *ptr) if (ptr == NULL) return; - a = ptr - sizeof(*a); + a = (struct os_alloc_trace *) ptr - 1; if (a->magic != ALLOC_MAGIC) { wpa_printf(MSG_INFO, "FREE[%p]: invalid magic 0x%x%s", a, a->magic,