Author: dreiss
Date: Mon Sep 13 17:32:13 2010
New Revision: 996609
URL: http://svn.apache.org/viewvc?rev=996609&view=rev
Log:
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.
Modified:
incubator/thrift/trunk/compiler/cpp/src/parse/t_const_value.h
Modified: incubator/thrift/trunk/compiler/cpp/src/parse/t_const_value.h
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/parse/t_const_value.h?rev=996609&r1=996608&r2=996609&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/parse/t_const_value.h (original)
+++ incubator/thrift/trunk/compiler/cpp/src/parse/t_const_value.h Mon Sep 13
17:32:13 2010
@@ -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_;