From: Andrii Simiklit Date: Wed, 3 Jun 2020 15:59:02 +0000 (+0300) Subject: glsl: fix crash on glsl macro redefinition X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c711beb5ce9fe013d557be71eb986444415b758;p=mesa.git glsl: fix crash on glsl macro redefinition In case shader contains two equal macro defines, first one with trailing spaces and the second one without. `#define A 1 ` `#define A 1` The parser crashes Fixes: 0346ad37741b11d640c1c4970b275c1f0c7f9e75 ("glsl: ignore trailing whitespace when define redefined") Reviewed-by: Timothy Arceri Reviewed-by: Ian Romanick Signed-off-by: Andrii Simiklit Part-of: --- diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y index 2a8ea817a98..173e1a1586b 100644 --- a/src/compiler/glsl/glcpp/glcpp-parse.y +++ b/src/compiler/glsl/glcpp/glcpp-parse.y @@ -1187,6 +1187,9 @@ _token_list_equal_ignoring_space(token_list_t *a, token_list_t *b) node_b = node_b->next; } + if (node_a == NULL && node_b == NULL) + break; + if (node_b == NULL && node_a->token->type == SPACE) { while (node_a && node_a->token->type == SPACE) node_a = node_a->next;