Fix readBytes and writeBytes methods in fastjson2 (#13968)

This commit is contained in:
TomlongTK 2024-03-21 16:26:20 +08:00 committed by GitHub
parent afcf04d6e3
commit 164aebf6ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -91,7 +91,7 @@ public class FastJson2ObjectInput implements ObjectInput {
@Override @Override
public byte[] readBytes() throws IOException { public byte[] readBytes() throws IOException {
int length = is.read(); int length = readLength();
byte[] bytes = new byte[length]; byte[] bytes = new byte[length];
int read = is.read(bytes, 0, length); int read = is.read(bytes, 0, length);
if (read != length) { if (read != length) {

View File

@ -89,13 +89,13 @@ public class FastJson2ObjectOutput implements ObjectOutput {
@Override @Override
public void writeBytes(byte[] b) throws IOException { public void writeBytes(byte[] b) throws IOException {
os.write(b.length); writeLength(b.length);
os.write(b); os.write(b);
} }
@Override @Override
public void writeBytes(byte[] b, int off, int len) throws IOException { public void writeBytes(byte[] b, int off, int len) throws IOException {
os.write(len); writeLength(len);
os.write(b, off, len); os.write(b, off, len);
} }