libsepol: resolve GCC warning about null-dereference
GCC reports a NULL dereference of the return value of stack_peek(). This function explicitly returns NULL in case of 'stack->pos == -1'. Error out on NULL returned. module_to_cil.c: In function ‘block_to_cil’: module_to_cil.c:3357:55: error: potential null pointer dereference [-Werror=null-dereference] 3357 | struct list *alias_list = typealias_lists[decl->decl_id]; | ~~~~^~~~~~~~~ There are more occurrences of unconditionally dereferencing the return value of stack_peek(), but the callers should ensure a valid stack, so just silence this single warning. Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
parent
a9f4a2cb32
commit
e0968a8640
|
@ -3354,9 +3354,14 @@ static int typealiases_to_cil(int indent, struct policydb *pdb, struct avrule_bl
|
|||
char *type_name;
|
||||
struct list_node *curr;
|
||||
struct avrule_decl *decl = stack_peek(decl_stack);
|
||||
struct list *alias_list = typealias_lists[decl->decl_id];
|
||||
struct list *alias_list;
|
||||
int rc = -1;
|
||||
|
||||
if (decl == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
alias_list = typealias_lists[decl->decl_id];
|
||||
if (alias_list == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue