From 79ebcbec4b3b3e30b3911afee9e1b1e761ffdeb9 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 26 Jun 2012 11:21:33 -0700 Subject: [PATCH] Fix crash in SwitchStmt::TypeCheck() with malformed programs. --- stmt.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stmt.cpp b/stmt.cpp index ade7e1ed..64f1b10d 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -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();