Fixed UBSan report in ProtobufWriter

This commit is contained in:
Alexey Milovidov 2019-07-25 23:10:33 +03:00
parent c3f82f0b8c
commit bc74013f98

View File

@ -141,7 +141,8 @@ void ProtobufWriter::SimpleWriter::endMessage()
size_t size_of_message = buffer.size() - num_bytes_skipped;
writeVarint(size_of_message, out);
for (const auto & piece : pieces)
out.write(reinterpret_cast<char *>(&buffer[piece.start]), piece.end - piece.start);
if (piece.end > piece.start)
out.write(reinterpret_cast<char *>(&buffer[piece.start]), piece.end - piece.start);
buffer.clear();
pieces.clear();
num_bytes_skipped = 0;