diff mbox

[5/5] libsepol/cil: free bitmaps in cil_level_equals()

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

Commit Message

Nicolas Iooss Feb. 19, 2017, 10:30 a.m. UTC
cil_level_equals() builds two bitmap and compare them but does not
destroy them before returning the result.

This memory leak has been found by running clang's Address Sanitizer on
a set of policies generated by American Fuzzy Lop.

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

Patch

diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
index 15833c1322e2..7c40ad0c5ed8 100644
--- a/libsepol/cil/src/cil.c
+++ b/libsepol/cil/src/cil.c
@@ -1299,7 +1299,9 @@  static int cil_level_equals(struct cil_level *low, struct cil_level *high)
 		goto exit;
 	}
 
-	return ebitmap_cmp(&elow, &ehigh);
+	rc = ebitmap_cmp(&elow, &ehigh);
+	ebitmap_destroy(&elow);
+	ebitmap_destroy(&ehigh);
 
 exit:
 	return rc;