binpac: Fixing crash with undefined case expressions.

Found by Emmanuele Zambon.
This commit is contained in:
Robin Sommer 2011-04-11 08:22:16 -07:00 committed by Tim Wojtulewicz
parent e7e2ee38e7
commit d41a2def5a

View file

@ -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));