diff mbox series

[3/5] libsepol: free ebitmap in filename_trans_comp_read_one()

Message ID 20230713180816.101924-3-cgzones@googlemail.com (mailing list archive)
State Not Applicable
Delegated to: Petr Lautrbach
Headers show
Series [1/5] libsepol: free memory on str_read() failures | expand

Commit Message

Christian Göttsche July 13, 2023, 6:08 p.m. UTC
ebitmap_read() might fail in between, but always calls ebitmap_init(),
so ebitmap_destopy() is safe to call.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/avtab.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
index 7b85519b..9c7daf8e 100644
--- a/libsepol/src/avtab.c
+++ b/libsepol/src/avtab.c
@@ -912,7 +912,7 @@  static int filename_trans_comp_read_one(avtab_t *a, void *fp)
 	for (i = 0; i < ndatum; i++) {
 		rc = ebitmap_read(&stypes, fp);
 		if (rc < 0)
-			goto err;
+			goto err_ebitmap;
 
 		rc = next_entry(buf, fp, sizeof(uint32_t));
 		if (rc < 0)
@@ -928,6 +928,8 @@  static int filename_trans_comp_read_one(avtab_t *a, void *fp)
 			if (rc < 0)
 				goto err_ebitmap;
 		}
+
+		ebitmap_destroy(&stypes);
 	}
 
 	free(name);