diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c index 0894fcbf35..a4630685b1 100644 --- a/checkpolicy/policy_define.c +++ b/checkpolicy/policy_define.c @@ -2056,7 +2056,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))) { @@ -2117,6 +2118,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); @@ -2156,7 +2158,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; }