From b0ccffd332154920f39456831af4256cd566a7c8 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Wed, 16 Sep 2015 18:34:21 +0000 Subject: [PATCH] this will happen on systems that don't have mmap(2). Typically MALLOC type entries happen during regular parsing or compilation and are allocated in coalesce_entries(). But they will also occur when QUICK is not defined (i.e. when the target system does not have mmap(2)). --- src/apprentice.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/apprentice.c b/src/apprentice.c index 6c0a4464..98a422da 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.238 2015/09/12 18:10:42 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.239 2015/09/16 18:21:26 christos Exp $") #endif /* lint */ #include "magic.h" @@ -553,9 +553,13 @@ apprentice_unmap(struct magic_map *map) break; #endif case MAP_TYPE_MALLOC: - free(map->p); - for (i = 0; i < MAGIC_SETS; i++) + for (i = 0; i < MAGIC_SETS; i++) { + if ((char *)map->magic[i] >= (char *)map->p && + (char *)map->magic[i] < (char *)map->p + map->len) + continue; free(map->magic[i]); + } + free(map->p); break; case MAP_TYPE_USER: break; -- 2.50.1