From: Christos Zoulas Date: Tue, 11 Nov 2014 17:46:05 +0000 (+0000) Subject: fix memory leak. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c45abc8c31416be26e5adf797783bfa450284c9;p=file fix memory leak. --- diff --git a/src/apprentice.c b/src/apprentice.c index 1824a182..6085bfb2 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.221 2014/10/29 14:41:32 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.222 2014/11/11 17:46:05 christos Exp $") #endif /* lint */ #include "magic.h" @@ -564,19 +564,19 @@ mlist_alloc(void) private void mlist_free(struct mlist *mlist) { - struct mlist *ml; + struct mlist *ml, *next; if (mlist == NULL) return; - for (ml = mlist->next; ml != mlist;) { - struct mlist *next = ml->next; + ml = mlist->next; + for (ml = mlist->next; (next = ml->next) != NULL; ml = next) { if (ml->map) apprentice_unmap(ml->map); free(ml); - ml = next; + if (ml == mlist) + break; } - free(ml); } #ifndef COMPILE_ONLY