Function serializing string first converted its size to little-endian and
then used the converted value as actual size. This could have worked only
on little-endian machines and could cause undefined behaviour on big-endian.
Change-Id: Ica742b1d33b14e056f8c2322e39ffd7371e7ae14
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
static void serialize(IStream &stream, const std::string &str) {
uint32_t length = htole32(static_cast<uint32_t>(str.size()));
stream.write(sizeof(length), &length);
- stream.write(length, str.c_str());
+ stream.write(str.size(), str.c_str());
}
static void serializeNoSize(IStream &stream, const std::string &str) {
int length = str.size();