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") Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- libselinux/src/label.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libselinux/src/label.c b/libselinux/src/label.c index a03192e5..586e5e5e 100644 --- a/libselinux/src/label.c +++ b/libselinux/src/label.c @@ -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; -- 2.35.2