summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java2
-rw-r--r--java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java2
2 files changed, 4 insertions, 0 deletions
diff --git a/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java b/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java
index 3e3926c..cf1dc67 100644
--- a/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java
+++ b/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java
@@ -243,6 +243,8 @@ public final class CodedInputStreamMicro {
final ByteStringMicro result = ByteStringMicro.copyFrom(buffer, bufferPos, size);
bufferPos += size;
return result;
+ } else if (size == 0) {
+ return ByteStringMicro.EMPTY;
} else {
// Slow path: Build a byte array first then copy it.
return ByteStringMicro.copyFrom(readRawBytes(size));
diff --git a/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java b/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
index c5fea5a..df7fee0 100644
--- a/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
+++ b/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
@@ -236,6 +236,8 @@ public final class CodedInputByteBufferNano {
System.arraycopy(buffer, bufferPos, result, 0, size);
bufferPos += size;
return result;
+ } else if (size == 0) {
+ return WireFormatNano.EMPTY_BYTES;
} else {
// Slow path: Build a byte array first then copy it.
return readRawBytes(size);