eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
798 stars 349 forks source link

Skip optionals completely when deserializing a key #2040

Closed eboasson closed 2 weeks ago

eboasson commented 2 weeks ago

The serialized key only contains the key fields and when deserializing a key one must skip everything else. The deserialization (and printing) code incorrectly read the boolean indicating presence of an optional field in cases like:

struct S {
  @optional long x;
  @key long y;
};

This commit fixes it by first checking whether a key is being deserialized, skipping the checks for the presence of an optional field if it is. (Note that optional fields can not be key fields.)