Mesa (9.1): glsl: Bail on parsing if the #version directive is bogus.
Ian Romanick
idr at kemper.freedesktop.org
Wed Jun 26 17:58:38 UTC 2013
Module: Mesa
Branch: 9.1
Commit: 2385fe475e845ba1ae162e56852878914fa2a79a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2385fe475e845ba1ae162e56852878914fa2a79a
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Fri Jun 7 21:46:04 2013 -0700
glsl: Bail on parsing if the #version directive is bogus.
If we didn't successfully parse the #version line, there's no point in
continuing with parsing and compiling: it's already failed.
Furthermore, it can actually be harmful: right after handling #version,
we call _mesa_glsl_initialize_types(), which checks state->es_shader and
language_version. If it isn't valid, it hits an assertion failure.
Fixes Piglit's "invalid-version-es." When processing "#version 110 es",
our code set state->es_shader and state->language_version = 110. It
then properly determined that this was invalid and flagged an error.
Since we continued anyway, we hit the assertion mentioned above.
NOTE: This is a candidate for the 9.1 branch.
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
(cherry picked from commit f730b1f72a13aa1e749beeb50f8e8c5929bf2c45)
---
src/glsl/glsl_parser.yy | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 154ce2d..2842160 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -265,10 +265,16 @@ version_statement:
| VERSION_TOK INTCONSTANT EOL
{
state->process_version_directive(&@2, $2, NULL);
+ if (state->error) {
+ YYERROR;
+ }
}
| VERSION_TOK INTCONSTANT any_identifier EOL
{
state->process_version_directive(&@2, $2, $3);
+ if (state->error) {
+ YYERROR;
+ }
}
;
More information about the mesa-commit
mailing list