Fix large message writing

This commit is contained in:
Kai S. K. Engelbart 2020-07-04 08:55:06 +02:00
parent 16b0a338a7
commit 5f4f626206
No known key found for this signature in database
GPG Key ID: 0A48559CA32CB48F

View File

@ -67,7 +67,7 @@ public class Message {
while (this.length + remaining > capacity) while (this.length + remaining > capacity)
if (!this.messageBuffer.expandMessage(this)) return -1; if (!this.messageBuffer.expandMessage(this)) return -1;
int bytesToCopy = Math.min(remaining, capacity - length); int bytesToCopy = Math.min(remaining, capacity - this.length);
System.arraycopy(byteArray, offset, sharedArray, this.offset + this.length, bytesToCopy); System.arraycopy(byteArray, offset, sharedArray, this.offset + this.length, bytesToCopy);
this.length += bytesToCopy; this.length += bytesToCopy;
return bytesToCopy; return bytesToCopy;