From 45cc1a4b090045bfa635c40f6cc9ca45f6d37fbc Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Tue, 9 Mar 2004 18:52:08 +0000 Subject: [PATCH] Fix possible memory leak on error Dmitry V. Levin" --- src/apprentice.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apprentice.c b/src/apprentice.c index 33ce218f..9adbd4ab 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -50,7 +50,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$Id: apprentice.c,v 1.73 2004/03/07 16:16:14 christos Exp $") +FILE_RCSID("@(#)$Id: apprentice.c,v 1.74 2004/03/09 18:52:08 christos Exp $") #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -166,14 +166,14 @@ apprentice_1(struct magic_set *ms, const char *fn, int action, return rv; mapped = rv; - if ((ml = malloc(sizeof(*ml))) == NULL) { + if (magic == NULL || nmagic == 0) { file_delmagic(magic, mapped, nmagic); - file_oomem(ms); return -1; } - if (magic == NULL || nmagic == 0) { + if ((ml = malloc(sizeof(*ml))) == NULL) { file_delmagic(magic, mapped, nmagic); + file_oomem(ms); return -1; } -- 2.40.0