From: Bryan Duxbury Date: Wed, 23 Jun 2010 16:57:51 +0000 (+0000) Subject: THRIFT-808. Segfault when constant declaration references a struct field that doesn... X-Git-Tag: 0.4.0~55 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=656683c776f594da98b8df6d00fcb2a316d56171;p=common%2Fthrift.git THRIFT-808. Segfault when constant declaration references a struct field that doesn't exist This patch causes a useful error to be printed instead of an anonymous segfault. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@957270 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/parse/t_scope.h b/compiler/cpp/src/parse/t_scope.h index d3f9d261..585b9107 100644 --- a/compiler/cpp/src/parse/t_scope.h +++ b/compiler/cpp/src/parse/t_scope.h @@ -96,6 +96,9 @@ class t_scope { std::map::const_iterator v_iter; for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) { t_field* field = tstruct->get_field_by_name(v_iter->first->get_string()); + if (field == NULL) { + throw "No field named \"" + v_iter->first->get_string() + "\" was found in struct of type \"" + tstruct->get_name() + "\""; + } resolve_const_value(v_iter->second, field->get_type()); } } else if (const_val->get_type() == t_const_value::CV_IDENTIFIER) {