diff mbox

[4/5] libselinux: always free catalog in db_init()

Message ID 20170115130359.6108-4-nicolas.iooss@m4x.org (mailing list archive)
State Not Applicable
Headers show

Commit Message

Nicolas Iooss Jan. 15, 2017, 1:03 p.m. UTC
This variable may be leaked in some error paths.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/label_db.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libselinux/src/label_db.c b/libselinux/src/label_db.c
index 1155bcc84031..c46d0a1de9a7 100644
--- a/libselinux/src/label_db.c
+++ b/libselinux/src/label_db.c
@@ -281,9 +281,12 @@  db_init(const struct selinux_opt *opts, unsigned nopts,
 		free(catalog);
 		return NULL;
 	}
-	if (fstat(fileno(filp), &sb) < 0)
+	if (fstat(fileno(filp), &sb) < 0) {
+		free(catalog);
 		return NULL;
+	}
 	if (!S_ISREG(sb.st_mode)) {
+		free(catalog);
 		errno = EINVAL;
 		return NULL;
 	}