From d41a2def5a06d562ba7f4d6d50aebd1929532fce Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Mon, 11 Apr 2011 08:22:16 -0700 Subject: [PATCH] binpac: Fixing crash with undefined case expressions. Found by Emmanuele Zambon. --- tools/binpac/src/pac_expr.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/binpac/src/pac_expr.cc b/tools/binpac/src/pac_expr.cc index 02303bc953..2047d2269d 100644 --- a/tools/binpac/src/pac_expr.cc +++ b/tools/binpac/src/pac_expr.cc @@ -242,6 +242,11 @@ void Expr::GenCaseEval(Output *out_cc, Env *env) Type *val_type = DataType(env); ID *val_var = env->AddTempID(val_type); + // DataType(env) can return a null pointer if an enum value is not + // defined. + if ( ! val_type ) + throw Exception(this, "undefined case value"); + out_cc->println("%s %s;", val_type->DataTypeStr().c_str(), env->LValue(val_var));