aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2015-09-28 12:59:34 +0200
committerIago Toral Quiroga <[email protected]>2015-09-29 10:53:08 +0200
commit1dc2db7a4dfb0e88a51a27c2234b6a01dead80bf (patch)
tree85bc6613989f6b2dd0b06642a6c3fb54d75709d0
parent6bf718fec22f605702c7d15503d4dbc3c2be35e6 (diff)
glsl: Fix null return coverity warning
Add an assert on the result of as_dereference() not being NULL: >>> CID 1324978: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a null pointer "deref_record->record->as_dereference()". Since we are introducing a new variable to hold the result of as_dereference(), take the opportunity to rename deref_record_type to interface_type and just name the new variable interface_deref, which is less confusing. Reviewed-by: Kristian Høgsberg <[email protected]>
-rw-r--r--src/glsl/lower_ubo_reference.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 4e09b080e62..e581306019b 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -922,12 +922,14 @@ lower_ubo_reference_visitor::calculate_unsized_array_stride(ir_dereference *dere
case ir_type_dereference_record:
{
ir_dereference_record *deref_record = (ir_dereference_record *) deref;
- const struct glsl_type *deref_record_type =
- deref_record->record->as_dereference()->type;
- unsigned record_length = deref_record_type->length;
+ ir_dereference *interface_deref =
+ deref_record->record->as_dereference();
+ assert(interface_deref != NULL);
+ const struct glsl_type *interface_type = interface_deref->type;
+ unsigned record_length = interface_type->length;
/* Unsized array is always the last element of the interface */
const struct glsl_type *unsized_array_type =
- deref_record_type->fields.structure[record_length - 1].type->fields.array;
+ interface_type->fields.structure[record_length - 1].type->fields.array;
const bool array_row_major =
is_dereferenced_thing_row_major(deref_record);