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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This variable may be leaked in some error paths.

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

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;
 	}
-- 
2.11.0

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux