glsl/glcpp: fix SIGSEGV when checking error condition for macro redefinition
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Thu, 23 Jul 2015 08:38:36 +0000 (10:38 +0200)
committerSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Fri, 24 Jul 2015 05:01:13 +0000 (07:01 +0200)
Commit a6e9cd14c does not take into account than node_{a,b}->next could be NULL
in some circumstances, such as in a shader containing this code:

  #define A 1 /* comment */
  #define A 1 /* comment */

This patch fixes the segmentation fault for cases like that.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91290
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Cc: mesa-stable@lists.freedesktop.org
src/glsl/glcpp/glcpp-parse.y

index 7ef4dfd531657950ff64bff6f48d015f5b67a345..dd5ec2a30b577600b5e6715607dfb88c4a15e050 100644 (file)
@@ -1074,9 +1074,9 @@ _token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
                 */
                if (node_a->token->type == SPACE
                    && node_b->token->type == SPACE) {
-                       while (node_a->token->type == SPACE)
+                       while (node_a && node_a->token->type == SPACE)
                                node_a = node_a->next;
-                       while (node_b->token->type == SPACE)
+                       while (node_b && node_b->token->type == SPACE)
                                node_b = node_b->next;
                        continue;
                }