Skip to content

Commit

Permalink
[protobuf] Removed size check on cpp message types in protobuf reflec…
Browse files Browse the repository at this point in the history
…tion. (#1730)

Empty message fields are visible, e.g. in eCAL monitor protobuf reflection plugin
  • Loading branch information
Peguen committed Sep 9, 2024
1 parent 6f880f8 commit 3d67561
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions contrib/ecalproto/src/ecal_proto_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,8 @@ namespace protobuf
// do not process default messages to avoid infinite recursions.
std::vector<const google::protobuf::FieldDescriptor*> msg_fields;
msg.GetReflection()->ListFields(msg, &msg_fields);
if (msg_fields.size() > 0)
{
ProcProtoMsg(msg, name.str(), complete_message_name, true, fnum);
}

ProcProtoMsg(msg, name.str(), complete_message_name, true, fnum);
}
}
}
Expand All @@ -284,10 +282,8 @@ namespace protobuf
// do not process default messages to avoid infinite recursions.
std::vector<const google::protobuf::FieldDescriptor*> msg_fields;
msg.GetReflection()->ListFields(msg, &msg_fields);
if (msg_fields.size() > 0)
{
ProcProtoMsg(msg, field->name(), complete_message_name, false, field->number());
}

ProcProtoMsg(msg, field->name(), complete_message_name, false, field->number());
}
}
break;
Expand Down
12 changes: 4 additions & 8 deletions samples/cpp/pubsub/protobuf/proto_dyn/src/proto_dyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,8 @@ void ProcProtoMsg(const google::protobuf::Message& msg_, const std::string& pref
// do not process default messages to avoid infinite recursions.
std::vector<const google::protobuf::FieldDescriptor*> msg_fields;
msg.GetReflection()->ListFields(msg, &msg_fields);
if (msg_fields.size() > 0)
{
ProcProtoMsg(msg, prefix);
}

ProcProtoMsg(msg, prefix);
}
}
else
Expand All @@ -258,10 +256,8 @@ void ProcProtoMsg(const google::protobuf::Message& msg_, const std::string& pref
// do not process default messages to avoid infinite recursions.
std::vector<const google::protobuf::FieldDescriptor*> msg_fields;
msg.GetReflection()->ListFields(msg, &msg_fields);
if (msg_fields.size() > 0)
{
ProcProtoMsg(msg, prefix);
}

ProcProtoMsg(msg, prefix);
}
}
break;
Expand Down

0 comments on commit 3d67561

Please sign in to comment.