Fix crash in SwitchStmt::TypeCheck() with malformed programs.

This commit is contained in:
Matt Pharr
2012-06-26 11:21:33 -07:00
parent 2c7b650240
commit 79ebcbec4b

View File

@@ -2586,9 +2586,12 @@ SwitchStmt::Print(int indent) const {
Stmt *
SwitchStmt::TypeCheck() {
const Type *exprType = expr->GetType();
if (exprType == NULL)
const Type *exprType;
if (expr == NULL ||
(exprType = expr->GetType()) == NULL) {
Assert(m->errorCount > 0);
return NULL;
}
const Type *toType = NULL;
exprType = exprType->GetAsConstType();