فهرست منبع

Handle 0-length byte buffers in micro and nano protobufs

Change-Id: I845ee1ab1005d25c8d77a8c2ed801c0f7b7c847b
Andre Eisenbach 10 سال پیش
والد
کامیت
15bff99de6
1فایلهای تغییر یافته به همراه2 افزوده شده و 0 حذف شده
  1. 2 0
      javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java

+ 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);