Skip to content

Commit

Permalink
Add a guard for empty splices
Browse files Browse the repository at this point in the history
  • Loading branch information
osa1 committed Oct 24, 2023
1 parent 0822f4c commit 7f2b6b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion protobuf/lib/src/protobuf/coded_buffer_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,11 @@ class CodedBufferWriter {
/// Add TypedData splice - these bytes would be directly copied into the
/// output buffer by [writeTo].
void writeRawBytes(TypedData value) {
final length = value.lengthInBytes;
if (length == 0) return;
_commitSplice();
_splices.add(value);
_bytesTotal += value.lengthInBytes;
_bytesTotal += length;
}

/// Start writing a length-delimited data.
Expand Down

0 comments on commit 7f2b6b1

Please sign in to comment.