[Mesa-stable] [PATCH 2/2] glsl: Make sure not to dereference NULL

Matt Turner mattst88 at gmail.com
Mon Jul 6 11:02:59 PDT 2015


On Sat, Jul 4, 2015 at 2:40 PM, Neil Roberts <neil at linux.intel.com> wrote:
> In this bit of code point_five can be NULL if the expression is not a
> constant. This fixes it to match the pattern of the rest of the chunk
> of code so that it checks for NULLs.
>
> Cc: Matt Turner <mattst88 at gmail.com>
> Cc: "10.6" <mesa-stable at lists.freedesktop.org>
> ---
>  src/glsl/opt_algebraic.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index 9b8a426..c4b8715 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -589,7 +589,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>                 continue;
>
>              ir_constant *point_five = add_expr->operands[1 - j]->as_constant();
> -            if (!point_five->is_value(0.5, 0))
> +            if (!point_five || !point_five->is_value(0.5, 0))
>                 continue;
>
>              if (abs_expr->operands[0]->equals(sign_expr->operands[0])) {
> --
> 1.9.3
>

Whoops. I think I thought that is_value NULL checked 'this'.

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-stable mailing list