diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c index 81427e65..305567a5 100644 --- a/libsepol/src/kernel_to_cil.c +++ b/libsepol/src/kernel_to_cil.c @@ -2497,9 +2497,10 @@ static int write_user_decl_rules_to_cil(FILE *out, struct policydb *pdb) sepol_printf(out, ")\n"); } - strs_destroy(&strs); - exit: + if (strs) + strs_destroy(&strs); + if (rc != 0) { sepol_log_err("Error writing user declarations to CIL\n"); } diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c index 179f0ad1..eb72e4ac 100644 --- a/libsepol/src/kernel_to_conf.c +++ b/libsepol/src/kernel_to_conf.c @@ -2375,9 +2375,10 @@ static int write_user_decl_rules_to_conf(FILE *out, struct policydb *pdb) sepol_printf(out, ";\n"); } - strs_destroy(&strs); - exit: + if (strs) + strs_destroy(&strs); + if (rc != 0) { sepol_log_err("Error writing user declarations to policy.conf\n"); }