THRIFT-808. Segfault when constant declaration references a struct field that doesn...
authorBryan Duxbury <bryanduxbury@apache.org>
Wed, 23 Jun 2010 16:57:51 +0000 (16:57 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Wed, 23 Jun 2010 16:57:51 +0000 (16:57 +0000)
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

compiler/cpp/src/parse/t_scope.h

index d3f9d26..585b910 100644 (file)
@@ -96,6 +96,9 @@ class t_scope {
       std::map<t_const_value*, t_const_value*>::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) {