diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c index 5b8ed19e..c6f1659c 100644 --- a/libsepol/src/module_to_cil.c +++ b/libsepol/src/module_to_cil.c @@ -1917,10 +1917,12 @@ exit: free(new_val); free(val1); free(val2); - while ((val1 = stack_pop(stack)) != NULL) { - free(val1); + if (stack != NULL) { + while ((val1 = stack_pop(stack)) != NULL) { + free(val1); + } + stack_destroy(&stack); } - stack_destroy(&stack); return rc; }