You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2011/10/07 02:25:46 UTC

svn commit: r1179909 - /thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc

Author: jfarrell
Date: Fri Oct  7 00:25:46 2011
New Revision: 1179909

URL: http://svn.apache.org/viewvc?rev=1179909&view=rev
Log:
Thrift-1379: fix uninitialized enum values in thrift C++ objects
Client: cpp
Patch: Dave Watson

The thrift-generated code for C++ class objects does not provide any
initialization for enum values, so they wind up containing random/uninitialized
data. This causes problems when clients do not send argument data, as the server
receives random data rather than zero for unpassed args.
Enums should be initialized to zero.


Modified:
    thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc

Modified: thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc?rev=1179909&r1=1179908&r2=1179909&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc Fri Oct  7 00:25:46 2011
@@ -847,7 +847,7 @@ void t_cpp_generator::generate_struct_de
 
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       t_type* t = get_true_type((*m_iter)->get_type());
-      if (t->is_base_type()) {
+      if (t->is_base_type() || t->is_enum()) {
         string dval;
         if (t->is_enum()) {
           dval += "(" + type_name(t) + ")";