From: Christos Zoulas Date: Thu, 10 Sep 2015 13:59:47 +0000 (+0000) Subject: don't leak memory when loading non-compiled files. X-Git-Tag: FILE5_25~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3aa35aaed2ea8d6285b79dacc899358c112caceb;p=file don't leak memory when loading non-compiled files. --- diff --git a/src/apprentice.c b/src/apprentice.c index 27ed39c6..dab9af77 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.233 2015/06/10 00:57:41 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.234 2015/07/27 09:12:32 christos Exp $") #endif /* lint */ #include "magic.h" @@ -540,6 +540,7 @@ free: private void apprentice_unmap(struct magic_map *map) { + size_t i; if (map == NULL) return; @@ -552,6 +553,8 @@ apprentice_unmap(struct magic_map *map) #endif case MAP_TYPE_MALLOC: free(map->p); + for (i = 0; i < MAGIC_SETS; i++) + free(map->magic[i]); break; case MAP_TYPE_USER: break; @@ -1288,6 +1291,7 @@ apprentice_load(struct magic_set *ms, const char *fn, int action) file_oomem(ms, sizeof(*map)); return NULL; } + map->type = MAP_TYPE_MALLOC; /* print silly verbose header for USG compat. */ if (action == FILE_CHECK)