]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
trace: Fix void pointer arithmetic
authorMasashi Honma <honma@ictec.co.jp>
Thu, 26 Aug 2010 15:35:55 +0000 (18:35 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 26 Aug 2010 15:35:55 +0000 (18:35 +0300)
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.

src/utils/os_unix.c

index cb23f72074c2af639569ed8bfb82939eac49a63d..6f58fa46cf014d2cde99ebd88cf2066e8ce34a71 100644 (file)
@@ -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,