From: Alexander Monakov Date: Tue, 27 Jun 2017 17:58:47 +0000 (+0300) Subject: fix undefined behavior in free X-Git-Tag: v1.1.17~41 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=60ab365cae24063b0f21821860ca16fb63e81f81;p=oweals%2Fmusl.git fix undefined behavior in free --- diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c index d5ee4280..9e05e1d6 100644 --- a/src/malloc/malloc.c +++ b/src/malloc/malloc.c @@ -450,14 +450,15 @@ copy_realloc: void free(void *p) { - struct chunk *self = MEM_TO_CHUNK(p); - struct chunk *next; + struct chunk *self, *next; size_t final_size, new_size, size; int reclaim=0; int i; if (!p) return; + self = MEM_TO_CHUNK(p); + if (IS_MMAPPED(self)) { size_t extra = self->psize; char *base = (char *)self - extra;