From 865b363f43e63b5d5e5c0ae5511f8e2959dca67d Mon Sep 17 00:00:00 2001 From: KerstinKeller Date: Fri, 24 May 2024 13:33:24 +0200 Subject: [PATCH] [c#] Do not reuse Protobuf message objects in callbacks, as this cannot reset fields which are not contained on the wire. (#1593) (#1610) --- lang/csharp/Continental/eCAL/Protobuf/ProtoSubscriber.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lang/csharp/Continental/eCAL/Protobuf/ProtoSubscriber.cs b/lang/csharp/Continental/eCAL/Protobuf/ProtoSubscriber.cs index 11ce3670f0..7e0b9f1387 100644 --- a/lang/csharp/Continental/eCAL/Protobuf/ProtoSubscriber.cs +++ b/lang/csharp/Continental/eCAL/Protobuf/ProtoSubscriber.cs @@ -33,8 +33,6 @@ public ReceiveCallbackData() } }; - private ReceiveCallbackData receivedData; - /** * @brief Signature for a data callback. **/ @@ -50,7 +48,6 @@ public ProtobufSubscriber(string topicName) { T msg = new T(); binarySubscriber = new Subscriber(topicName, Common.ProtobufHelper.GetProtoMessageTypeName(msg), Common.ProtobufHelper.GetProtoMessageDescription(msg)); - receivedData = new ReceiveCallbackData(); } /** @@ -83,6 +80,7 @@ private void callBack(String topic, Core.Subscriber.ReceiveCallbackData data) byte[] messageBytes = Encoding.Default.GetBytes(data.data); MemoryStream msgStream = new MemoryStream(messageBytes); + var receivedData = new ReceiveCallbackData(); receivedData.data.MergeFrom(msgStream); receivedData.id = data.id; receivedData.clock = data.clock;