Module: Mesa Branch: glsl2 Commit: 570dc0d4004bf09d257b3e4c8664d3c26a8af510 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=570dc0d4004bf09d257b3e4c8664d3c26a8af510
Author: Eric Anholt <[email protected]> Date: Wed Jul 7 09:07:09 2010 -0700 glsl2: Avoid null deref in scalar constant unop expressions. --- src/glsl/ir_constant_expression.cpp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 541398a..98cbb6c 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -151,7 +151,12 @@ ir_constant_visitor::visit(ir_expression *ir) */ unsigned c0_inc = op0_scalar ? 1 : 0; unsigned c1_inc = op1_scalar ? 1 : 0; - unsigned components = op[op1_scalar ? 0 : 1]->type->components(); + unsigned components; + if (op1_scalar || !op[1]) { + components = op[0]->type->components(); + } else { + components = op[1]->type->components(); + } switch (ir->operation) { case ir_unop_logic_not: _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
