Mesa (glsl2): glcpp: Initialize location structure at beginning of parse.

Carl Worth cworth at kemper.freedesktop.org
Wed Aug 11 00:00:04 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 485f84d36608b4545fc5a0061f9ab3ac71b9e36e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=485f84d36608b4545fc5a0061f9ab3ac71b9e36e

Author: Carl Worth <cworth at cworth.org>
Date:   Tue Aug 10 16:58:28 2010 -0700

glcpp: Initialize location structure at beginning of parse.

Since we have a custom structure for YYLTYPE locations, we need to use
an %initial-action directive to avoid triggering use of uninitialized
memory when, for example, printing error messages.

We apparently don't yet have a test case that allowed valgrind to find
this bug for us, but valgrind found a similar problem in the other
parser, so we fix this one as well.

---

 src/glsl/glcpp/glcpp-parse.y |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index df1a649..a438357 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -142,7 +142,15 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
 
 %pure-parser
 %error-verbose
+
 %locations
+%initial-action {
+	@$.first_line = 1;
+	@$.first_column = 1;
+	@$.last_line = 1;
+	@$.last_column = 1;
+	@$.source = 0;
+}
 
 %parse-param {glcpp_parser_t *parser}
 %lex-param {glcpp_parser_t *parser}




More information about the mesa-commit mailing list