Add null check for results of dynamic_cast in AssignExpr::TypeCheck. Fixes coverity findings 1403416 and 1403417

This commit is contained in:
Tim Wojtulewicz 2019-09-13 12:34:04 -07:00
parent 40d4004453
commit 0140098adb

View file

@ -2187,7 +2187,19 @@ bool AssignExpr::TypeCheck(attr_list* attrs)
// we can create a new constructor now that the expected type // we can create a new constructor now that the expected type
// of LHS is known and let it do coercions where possible. // of LHS is known and let it do coercions where possible.
SetConstructorExpr* sce = dynamic_cast<SetConstructorExpr*>(op2); SetConstructorExpr* sce = dynamic_cast<SetConstructorExpr*>(op2);
if ( ! sce )
{
ExprError("Failed typecast to SetConstructorExpr");
return false;
}
ListExpr* ctor_list = dynamic_cast<ListExpr*>(sce->Op()); ListExpr* ctor_list = dynamic_cast<ListExpr*>(sce->Op());
if ( ! ctor_list )
{
ExprError("Failed typecast to ListExpr");
return false;
}
attr_list* attr_copy = 0; attr_list* attr_copy = 0;
if ( sce->Attrs() ) if ( sce->Attrs() )