]> granicus.if.org Git - file/commitdiff
PR/334: don't try to free the magic list if it was not allocated, since this
authorChristos Zoulas <christos@zoulas.com>
Fri, 14 Mar 2014 14:58:59 +0000 (14:58 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 14 Mar 2014 14:58:59 +0000 (14:58 +0000)
is an error.

src/apprentice.c

index 5eadbe05cc9ffd7ea7608b6b56e681833f106afa..5bc20b68c67573756b8c55b9652743b267ebb652 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.198 2014/03/06 16:18:53 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.199 2014/03/06 16:50:55 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -562,7 +562,8 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
        int file_err, errs = -1;
        size_t i;
 
-       file_reset(ms);
+       if (ms->mlist[0] != NULL)
+               file_reset(ms);
 
        if ((fn = magic_getpath(fn, action)) == NULL)
                return -1;