]> granicus.if.org Git - file/commitdiff
Fix memory leak (Anatol Belski)
authorChristos Zoulas <christos@zoulas.com>
Fri, 21 Feb 2014 14:32:48 +0000 (14:32 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 21 Feb 2014 14:32:48 +0000 (14:32 +0000)
src/softmagic.c

index 799e55c0343b79fad668bf7df8342639566ea3ed..170de9590690a128f0de5a1ddb0ffa11d12e5346 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.175 2014/02/18 11:09:31 kim Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.176 2014/02/18 17:59:21 kim Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -1762,12 +1762,16 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
                ms->offset = soffset;
                if (rv == 1) {
                        if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
-                           file_printf(ms, F(m->desc, "%u"), offset) == -1)
+                           file_printf(ms, F(m->desc, "%u"), offset) == -1) {
+                               free(rbuf);
                                return -1;
-                       if (file_printf(ms, "%s", rbuf) == -1)
+                       }
+                       if (file_printf(ms, "%s", rbuf) == -1) {
+                               free(rbuf);
                                return -1;
-                       free(rbuf);
+                       }
                }
+               free(rbuf);
                return rv;
 
        case FILE_USE: