glsl2: Initialize location structure at beginning of parse.
authorCarl Worth <cworth@cworth.org>
Tue, 10 Aug 2010 23:52:54 +0000 (16:52 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 10 Aug 2010 23:52:54 +0000 (16:52 -0700)
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.

Thanks to valgrind for noticing this bug.

src/glsl/glsl_parser.ypp

index 493b74fb69238f714014df3af1d914d07869e34a..3e60454bb24c0e7d0c95952d9b2dcf42d31c314f 100644 (file)
 %}
 
 %pure-parser
-%locations
 %error-verbose
 
+%locations
+%initial-action {
+   @$.first_line = 1;
+   @$.first_column = 1;
+   @$.last_line = 1;
+   @$.last_column = 1;
+   @$.source = 0;
+}
+
 %lex-param   {void *scanner}
 %parse-param {struct _mesa_glsl_parse_state *state}
 %name-prefix "_mesa_glsl_"