Browse Source

Merge pull request #345 from brianduff/update_aosp_again

Handle 0-length byte buffers in micro and nano protobufs
Jisi Liu 10 years ago
parent
commit
699db2d51a

+ 2 - 0
javanano/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);