You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2010/06/23 18:57:51 UTC

svn commit: r957270 - /incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h

Author: bryanduxbury
Date: Wed Jun 23 16:57:51 2010
New Revision: 957270

URL: http://svn.apache.org/viewvc?rev=957270&view=rev
Log:
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.

Modified:
    incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h

Modified: incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h?rev=957270&r1=957269&r2=957270&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h (original)
+++ incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h Wed Jun 23 16:57:51 2010
@@ -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) {