From 8d7667c27f1b116386d7970a130439f02ac4491d Mon Sep 17 00:00:00 2001 From: David Reiss Date: Mon, 13 Sep 2010 17:32:13 +0000 Subject: [PATCH] Don't segfault if t_enum::get_constant_by_name fails The recent enum change was causing t_enum::get_constant_by_name to fail in t_const_value::get_integer. This was causing a difficult-to-debug segfault. Check for failure and throw an exeception. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@996609 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/parse/t_const_value.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/cpp/src/parse/t_const_value.h b/compiler/cpp/src/parse/t_const_value.h index 5bfaeb23..b66372b9 100644 --- a/compiler/cpp/src/parse/t_const_value.h +++ b/compiler/cpp/src/parse/t_const_value.h @@ -72,6 +72,11 @@ class t_const_value { throw "have identifier \"" + get_identifier() + "\", but unset enum on line!"; } t_enum_value* val = enum_->get_constant_by_name(get_identifier()); + if (val == NULL) { + throw + "Unable to find enum value \"" + get_identifier() + + "\" in enum \"" + enum_->get_name() + "\""; + } return val->get_value(); } else { return intVal_; -- 2.17.1