If the insertion via the callback insertf fails, free the potential previously allocated transition hashtables. Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- libsepol/src/avtab.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c index 99fdaa87..6c74eff7 100644 --- a/libsepol/src/avtab.c +++ b/libsepol/src/avtab.c @@ -715,7 +715,12 @@ int avtab_read_item(struct policy_file *fp, uint32_t vers, avtab_t * a, } datum.data = le32_to_cpu(*buf32); } - return insertf(a, &key, &datum, p); + + rc = insertf(a, &key, &datum, p); + if (rc < 0) + avtab_trans_destroy(&trans); + + return rc; } static int avtab_insertf(avtab_t * a, avtab_key_t * k, avtab_datum_t * d, -- 2.40.1