[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH] lib/ukalloc: fix wrong return value in uk_malloc_ifpages
uk_malloc_ifpages returned the wrong pointer, because it added sizeof(size_t) to a pointer of type size_t. Hence, the return value wasn't offset from intptr by size_t bytes, but by size_t*size_t bytes. This patch makes intptr a void* in places in which its property as size_t* isn't used. Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx> --- lib/ukalloc/alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ukalloc/alloc.c b/lib/ukalloc/alloc.c index 52e9a77..2f5e364 100644 --- a/lib/ukalloc/alloc.c +++ b/lib/ukalloc/alloc.c @@ -167,7 +167,7 @@ static inline size_t uk_alloc_size_to_order(size_t size) void *uk_malloc_ifpages(struct uk_alloc *a, size_t size) { - size_t *intptr; + void *intptr; size_t order; size_t realsize = sizeof(order) + size; @@ -181,7 +181,7 @@ void *uk_malloc_ifpages(struct uk_alloc *a, size_t size) if (!intptr) return NULL; - *intptr = order; + *(size_t *)intptr = order; return intptr + sizeof(order); } @@ -229,7 +229,7 @@ void *uk_realloc_ifpages(struct uk_alloc *a, void *ptr, size_t size) int uk_posix_memalign_ifpages(struct uk_alloc *a, void **memptr, size_t align, size_t size) { - size_t *intptr; + void *intptr; size_t realsize; size_t order; @@ -259,7 +259,7 @@ int uk_posix_memalign_ifpages(struct uk_alloc *a, if (!intptr) return ENOMEM; - *intptr = order; + *(size_t *)intptr = order; *memptr = (void *) ALIGN_UP((uintptr_t)intptr + sizeof(order), align); return 0; } -- 2.18.0 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |