summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2017-06-27 20:58:47 +0300
committerRich Felker <dalias@aerifal.cx>2017-07-04 17:11:33 -0400
commit60ab365cae24063b0f21821860ca16fb63e81f81 (patch)
tree0c6f5611824e45ae2c5e72a618703ef3c24a4957
parentf6888840613a510c99915ba7732df8ec54d52637 (diff)
downloadmusl-60ab365cae24063b0f21821860ca16fb63e81f81.tar.gz
musl-60ab365cae24063b0f21821860ca16fb63e81f81.tar.bz2
musl-60ab365cae24063b0f21821860ca16fb63e81f81.tar.xz
musl-60ab365cae24063b0f21821860ca16fb63e81f81.zip
fix undefined behavior in free
-rw-r--r--src/malloc/malloc.c5
1 files changed, 3 insertions, 2 deletions
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;