summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-04-08 16:37:04 -0700
committerIan Romanick <[email protected]>2013-04-12 16:24:39 -0700
commit278c9af85e910f4625427c4e4ac27acf6eac02bf (patch)
tree4ffc5449726eb07c1644555ef3a3035ad8bff338
parentc6a86fb5639977f37a1403012669cdee86bbd89f (diff)
glsl: Fix hypothetical NULL dereference in ast_process_structure_or_interface_block
Fixes issue identified by Klocwork analysis: Pointer 'field_type' returned from call to function 'glsl_type' at line 4126 may be NULL and may be dereferenced at line 4139. Also there are 2 similar errors on line(s) 4165, 4174. In practice, it should be impossible to actually get NULL in here because a syntax error would have already caused compilation to halt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/glsl/ast_to_hir.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index a0ec71cde7b..050360debad 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3985,8 +3985,14 @@ ast_process_structure_or_interface_block(exec_list *instructions,
* blocks. All other types, arrays, and structures
* allowed for uniforms are allowed within a uniform
* block."
+ *
+ * It should be impossible for decl_type to be NULL here. Cases that
+ * might naturally lead to decl_type being NULL, especially for the
+ * is_interface case, will have resulted in compilation having
+ * already halted due to a syntax error.
*/
- const struct glsl_type *field_type = decl_type;
+ const struct glsl_type *field_type =
+ decl_type != NULL ? decl_type : glsl_type::error_type;
if (is_interface && field_type->contains_sampler()) {
YYLTYPE loc = decl_list->get_location();
@@ -4009,8 +4015,7 @@ ast_process_structure_or_interface_block(exec_list *instructions,
field_type = process_array_type(&loc, decl_type, decl->array_size,
state);
}
- fields[i].type = (field_type != NULL)
- ? field_type : glsl_type::error_type;
+ fields[i].type = field_type;
fields[i].name = decl->identifier;
if (qual->flags.q.row_major || qual->flags.q.column_major) {