diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c index 260e609d1..e056d141b 100644 --- a/checkpolicy/policy_define.c +++ b/checkpolicy/policy_define.c @@ -2060,7 +2060,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))) { @@ -2121,6 +2122,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); @@ -2160,7 +2162,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; }