]> git.tdb.fi Git - libs/gl.git/commitdiff
Check that the types of ternary branches exist before accessing them
authorMikko Rasa <tdb@tdb.fi>
Mon, 15 Mar 2021 09:13:36 +0000 (11:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 15 Mar 2021 09:15:21 +0000 (11:15 +0200)
This fixes a bug introduced in 3a1fe83 and triggered by 5e4204e.

source/glsl/generate.cpp

index 6430f9d8a0e53d630e284f64ef4ab869a2f85925..70b8ad18efbca4ca6279435c0f908bb8d37eae15 100644 (file)
@@ -908,6 +908,9 @@ void ExpressionResolver::visit(TernaryExpression &ternary)
        {
                BasicTypeDeclaration *basic_true = dynamic_cast<BasicTypeDeclaration *>(ternary.true_expr->type);
                BasicTypeDeclaration *basic_false = dynamic_cast<BasicTypeDeclaration *>(ternary.false_expr->type);
+               if(!basic_true || !basic_false)
+                       return;
+
                Compatibility compat = get_compatibility(*basic_true, *basic_false);
                if(compat==NOT_COMPATIBLE)
                        return;