Skip to content

Commit d05bc4a

Browse files
committed
src: fix reading empty string views in Blob[De]serializer
The string writing/reading was intended for debugging info in snapshot, which had a CHECK_GT(length, 0) check, it then got repurposed for SEA resource writing/reading and turned into a helper for string views, but was not updated to handle empty views, causing occasional crash in the CI when the read is protected. This patch fixes it.
1 parent 2246cd9 commit d05bc4a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/blob_serializer_deserializer-inl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ std::string_view BlobDeserializer<Impl>::ReadStringView(StringLogMode mode) {
139139
size_t length = ReadArithmetic<size_t>();
140140
Debug("ReadStringView(), length=%zu: ", length);
141141

142+
if (length == 0) {
143+
Debug("ReadStringView() read an empty view\n");
144+
return;
145+
}
146+
142147
std::string_view result(sink.data() + read_total, length);
143148
Debug("%p, read %zu bytes", result.data(), result.size());
144149
if (mode == StringLogMode::kAddressAndContent) {
@@ -269,6 +274,10 @@ size_t BlobSerializer<Impl>::WriteStringView(std::string_view data,
269274
size_t written_total = WriteArithmetic<size_t>(data.size());
270275

271276
size_t length = data.size();
277+
if (length == 0) {
278+
Debug("WriteStringView() wrote an empty view\n");
279+
return;
280+
}
272281
sink.insert(sink.end(), data.data(), data.data() + length);
273282
written_total += length;
274283

0 commit comments

Comments
 (0)