mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 04:10:09 +01:00
glcpp: Fix segfault when validating macro redefinitions
In _token_list_equal_ignoring_space(token_list_t*, token_list_t*), add a guard that prevents dereferncing a null token list. This fixes test src/glsl/glcpp/tests/092-redefine-macro-error-2.c and Bugzilla #32695.
This commit is contained in:
parent
c0cdae0368
commit
4fff52f1c9
1 changed files with 21 additions and 0 deletions
|
|
@ -824,11 +824,32 @@ _token_list_trim_trailing_space (token_list_t *list)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
_token_list_is_empty_ignoring_space (token_list_t *l)
|
||||
{
|
||||
token_node_t *n;
|
||||
|
||||
if (l == NULL)
|
||||
return 1;
|
||||
|
||||
n = l->head;
|
||||
while (n != NULL && n->token->type == SPACE)
|
||||
n = n->next;
|
||||
|
||||
return n == NULL;
|
||||
}
|
||||
|
||||
int
|
||||
_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
|
||||
{
|
||||
token_node_t *node_a, *node_b;
|
||||
|
||||
if (a == NULL || b == NULL) {
|
||||
int a_empty = _token_list_is_empty_ignoring_space(a);
|
||||
int b_empty = _token_list_is_empty_ignoring_space(b);
|
||||
return a_empty == b_empty;
|
||||
}
|
||||
|
||||
node_a = a->head;
|
||||
node_b = b->head;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue