make readByteArray not block indefinitely

This commit is contained in:
Daniella / Tove 2024-06-09 22:29:15 +02:00
parent 2f47747045
commit dead98e510
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -119,7 +119,7 @@ public class TypedInputStream {
public byte[] readByteArray() throws IOException {
byte[] bytes = new byte[readInt()];
int n = 0;
while ((n += stream.read(bytes, n, bytes.length - n)) != 0);
while (n != (n += stream.read(bytes, n, bytes.length - n)));
if(n != bytes.length) {
byte[] cutBytes = new byte[n];
System.arraycopy(bytes, 0, cutBytes, 0, n);