diff --git a/util/serialization.hh b/util/serialization.hh index 855e527592..206774c56a 100644 --- a/util/serialization.hh +++ b/util/serialization.hh @@ -219,6 +219,20 @@ void serialize_string(std::ostream& out, const sstring& s) { out.write(s.c_str(), s.size()); } +inline +void serialize_string(bytes::iterator& out, const sstring& s) { + for (char c : s) { + if (c == '\0') { + throw UTFDataFormatException(); + } + } + if (s.size() > std::numeric_limits::max()) { + throw UTFDataFormatException(); + } + serialize_int16(out, (uint16_t) s.size()); + out = std::copy(s.begin(), s.end(), out); +} + inline size_t serialize_string_size(const sstring& s) {; // As above, this code is missing the case of modified utf-8