libsepol: do not dereference a NULL pointer when stack_init() fails
In cond_expr_to_cil() when stack_init(&stack) fails, stack is set to NULL and the execution flow jumps to label "exit". This triggers a call to stack_pop(stack) which dereferences a NULL pointer in "if (stack->pos == -1)". This issue has been found using clang's static analyzer. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
5ed45797df
commit
a83f1cfd7e
1 changed files with 5 additions and 4 deletions
|
@ -1363,11 +1363,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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue