[Mesa-dev] [PATCH] glsl: fixed uninitialized pointer

Alejandro Piñeiro apinheiro at igalia.com
Thu May 12 07:50:33 UTC 2016


On 11/05/16 14:10, Jakob Sinclair wrote:
> Class "ir_constant" had a bunch of constructors where the pointer member
> "array_elements" had not been initialized. This could have lead to unsafe
> code if something had tried to write anything to it. This patch fixes
> this issue by initializing the pointer to NULL in all the constructors.
> This issue was discovered by Coverity.
>
> CID: 401603, 401604, 401605, 401610
>
> Signed-off-by: Jakob Sinclair <sinclair.jakob at openmailbox.org>

LGTM: Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>

> ---
>
> I don't have push access so anyone reviewing this patch could push it. Thank you!

Done:
https://cgit.freedesktop.org/mesa/mesa/commit/?id=18f7c88dd692409935bd74f82dc48f524cf951f6

>
>  src/compiler/glsl/ir.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
> index d69ab13..9637d7a 100644
> --- a/src/compiler/glsl/ir.cpp
> +++ b/src/compiler/glsl/ir.cpp
> @@ -663,12 +663,15 @@ ir_expression::variable_referenced() const
>  ir_constant::ir_constant()
>     : ir_rvalue(ir_type_constant)
>  {
> +   this->array_elements = NULL;
>  }
>  
>  ir_constant::ir_constant(const struct glsl_type *type,
>  			 const ir_constant_data *data)
>     : ir_rvalue(ir_type_constant)
>  {
> +   this->array_elements = NULL;
> +
>     assert((type->base_type >= GLSL_TYPE_UINT)
>  	  && (type->base_type <= GLSL_TYPE_BOOL));
>  
> @@ -744,6 +747,7 @@ ir_constant::ir_constant(bool b, unsigned vector_elements)
>  ir_constant::ir_constant(const ir_constant *c, unsigned i)
>     : ir_rvalue(ir_type_constant)
>  {
> +   this->array_elements = NULL;
>     this->type = c->type->get_base_type();
>  
>     switch (this->type->base_type) {
> @@ -759,6 +763,7 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i)
>  ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
>     : ir_rvalue(ir_type_constant)
>  {
> +   this->array_elements = NULL;
>     this->type = type;
>  
>     assert(type->is_scalar() || type->is_vector() || type->is_matrix()



More information about the mesa-dev mailing list