Skip to content

Truncated length of std::string #69

@mjopenglsdl

Description

@mjopenglsdl

I use protobuf to serialize some data into an std::string. the actual length is about 46, but aftering serializing the string with Fast-CDR the length becomes 19.
I have found that there was a byte with '\0' inside the protobuf serialized string, which has caused the size mismatch (because Fast-CDR uses c_str() of the string to find the length):

Cdr& serialize(const std::string &string_t) {return serialize(string_t.c_str());}

I think it is better to use the actual length of std::string, and I have provided a temporary solution:
https://github.com/mjopenglsdl/Fast-CDR/commit/fef4d2f2a7d40b79a96cef66f3a67e823cafac3f

There might be a better way to do it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions