Mesa (master): glsl/glcpp: fix SIGSEGV when checking error condition for macro redefinition

Samuel Iglesias Gonsálvez samuelig at kemper.freedesktop.org
Fri Jul 24 05:05:01 UTC 2015


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

Author: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
Date:   Thu Jul 23 10:38:36 2015 +0200

glsl/glcpp: fix SIGSEGV when checking error condition for macro redefinition

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 at igalia.com>
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Cc: mesa-stable at lists.freedesktop.org

---

 src/glsl/glcpp/glcpp-parse.y |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 7ef4dfd..dd5ec2a 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -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;
 		}




More information about the mesa-commit mailing list