From 0140098adb19f8fc4c26a6c702de4d131e19d959 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Fri, 13 Sep 2019 12:34:04 -0700 Subject: [PATCH] Add null check for results of dynamic_cast in AssignExpr::TypeCheck. Fixes coverity findings 1403416 and 1403417 --- src/Expr.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Expr.cc b/src/Expr.cc index 520bfb24c6..9eba79f02c 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -2187,7 +2187,19 @@ bool AssignExpr::TypeCheck(attr_list* attrs) // we can create a new constructor now that the expected type // of LHS is known and let it do coercions where possible. SetConstructorExpr* sce = dynamic_cast(op2); + if ( ! sce ) + { + ExprError("Failed typecast to SetConstructorExpr"); + return false; + } + ListExpr* ctor_list = dynamic_cast(sce->Op()); + if ( ! ctor_list ) + { + ExprError("Failed typecast to ListExpr"); + return false; + } + attr_list* attr_copy = 0; if ( sce->Attrs() )