From: Christos Zoulas Date: Wed, 16 Sep 2015 18:34:21 +0000 (+0000) Subject: this will happen on systems that don't have mmap(2). Typically X-Git-Tag: FILE5_26~142 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0ccffd332154920f39456831af4256cd566a7c8;p=file 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)). --- 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;