[File] Fix memory leak

Steve Grubb sgrubb at redhat.com
Sat Jun 6 15:16:45 UTC 2020


Hello,

I was running static analysis and it found a memory leak.

Signed-off-by: Steve Grubb <sgrubb at redhat.com>


diff --git a/src/ascmagic.c b/src/ascmagic.c
index 3bb73597..f2dfd155 100644
--- a/src/ascmagic.c
+++ b/src/ascmagic.c
@@ -164,8 +164,10 @@ file_ascmagic_with_encoding(struct magic_set *ms,
 			goto done;
 		}
 	}
-	if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)))
-		return 0;
+	if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION))) {
+		rv = 0;
+		goto done;
+	}
 
 	/* Now try to discover other details about the file. */
 	for (i = 0; i < ulen; i++) {





More information about the File mailing list