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) (#1731)

Empty message fields are visible, e.g. in eCAL monitor protobuf reflection plugin

Co-authored-by: Peguen <73380451+Peguen@users.noreply.github.com>
eclipse-ecal-bot and Peguen authored Sep 9, 2024
1 parent 6f880f8 commit 786bfbc
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
@@ -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);
}
}
}
@@ -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;
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
@@ -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
@@ -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;

0 comments on commit 786bfbc

Please sign in to comment.