Mesa (master): glsl: fix crash on glsl macro redefinition

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 10 05:18:36 UTC 2020


Module: Mesa
Branch: master
Commit: 2c711beb5ce9fe013d557be71eb986444415b758
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c711beb5ce9fe013d557be71eb986444415b758

Author: Andrii Simiklit <asimiklit.work at gmail.com>
Date:   Wed Jun  3 18:59:02 2020 +0300

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 <tarceri at itsqueeze.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Andrii Simiklit <andrii.simiklit at globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5312>

---

 src/compiler/glsl/glcpp/glcpp-parse.y | 3 +++
 1 file changed, 3 insertions(+)

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;



More information about the mesa-commit mailing list