diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c index 2167d62456..af9e0c497f 100644 --- a/checkpolicy/policy_define.c +++ b/checkpolicy/policy_define.c @@ -2064,7 +2064,8 @@ static int define_te_avtab_xperms_helper(int which, avrule_t ** rule) avrule->xperms = NULL; if (!avrule->source_filename) { yyerror("out of memory"); - return -1; + ret = -1; + goto out; } while ((id = queue_remove(id_queue))) { @@ -2125,6 +2126,7 @@ static int define_te_avtab_xperms_helper(int which, avrule_t ** rule) if (!cur_perms) { yyerror("out of memory"); ret = -1; + ebitmap_destroy(&tclasses); goto out; } class_perm_node_init(cur_perms); @@ -2164,7 +2166,11 @@ static int define_te_avtab_xperms_helper(int which, avrule_t ** rule) avrule->perms = perms; *rule = avrule; + return 0; out: + avrule_destroy(avrule); + free(avrule); + return ret; }