summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-04-19 14:06:27 -0600
committerBrian <[email protected]>2007-04-19 14:06:27 -0600
commit00da9afb8493a883b4a4db47484e875781c72c71 (patch)
treebab71026f2499949330536e7878ed777e4691384 /src/mesa
parent4abcaf3949a7ad9580a05d6029f2289adb4bcf03 (diff)
fix crash when program has invalid structure field
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index a928abd55db..f1761743dd2 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2320,15 +2320,16 @@ _slang_gen_field(slang_assemble_ctx * A, slang_operation *oper)
/* oper->a_id is the field name */
slang_ir_node *base, *n;
slang_typeinfo field_ti;
- GLint fieldSize, fieldOffset;
+ GLint fieldSize, fieldOffset = -1;
/* type of field */
slang_typeinfo_construct(&field_ti);
_slang_typeof_operation(A, oper, &field_ti);
fieldSize = _slang_sizeof_type_specifier(&field_ti.spec);
- fieldOffset = _slang_field_offset(&ti.spec, oper->a_id);
+ if (fieldSize > 0)
+ fieldOffset = _slang_field_offset(&ti.spec, oper->a_id);
- if (fieldOffset < 0) {
+ if (fieldSize == 0 || fieldOffset < 0) {
slang_info_log_error(A->log,
"\"%s\" is not a member of struct \"%s\"",
(char *) oper->a_id,