From 10ee4ecda644ed18226c92f075848fe064132e90 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Sun, 11 Sep 2016 13:53:02 +0000 Subject: [PATCH] PR/569: Shi Yin: Fix memory leak. --- src/apprentice.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apprentice.c b/src/apprentice.c index 47879b1f..f5958796 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.250 2016/07/05 19:20:19 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.251 2016/07/20 11:27:08 christos Exp $") #endif /* lint */ #include "magic.h" @@ -408,11 +408,11 @@ add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx) { struct mlist *ml; - mlp->map = idx == 0 ? map : NULL; + mlp->map = NULL; if ((ml = CAST(struct mlist *, malloc(sizeof(*ml)))) == NULL) return -1; - ml->map = NULL; + ml->map = idx == 0 ? map : NULL; ml->magic = map->magic[idx]; ml->nmagic = map->nmagic[idx]; @@ -556,7 +556,7 @@ apprentice_unmap(struct magic_map *map) case MAP_TYPE_MALLOC: for (i = 0; i < MAGIC_SETS; i++) { if ((char *)map->magic[i] >= (char *)map->p && - (char *)map->magic[i] < (char *)map->p + map->len) + (char *)map->magic[i] <= (char *)map->p + map->len) continue; free(map->magic[i]); } -- 2.40.0