libselinux: free memory on selabel_open(3) failure

If selabel_open(3) fails, e.g. when a specfile has the wrong file
permissions, free the memory allocated for digests.

Fixes: e40bbea9 ("libselinux: Add selabel_digest function")
Acked-by: James Carter <jwcart2@gmail.com>
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche 2022-04-13 17:56:32 +02:00 committed by James Carter
parent 63df12fec1
commit b9a4d13a30

View File

@ -226,6 +226,8 @@ struct selabel_handle *selabel_open(unsigned int backend,
rec->digest = selabel_is_digest_set(opts, nopts, rec->digest);
if ((*initfuncs[backend])(rec, opts, nopts)) {
if (rec->digest)
selabel_digest_fini(rec->digest);
free(rec->spec_file);
free(rec);
rec = NULL;