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
public byte[] readBytes() throws IOException {
int length = is.read();
int length = readLength();
byte[] bytes = new byte[length];
int read = is.read(bytes, 0, length);
if (read != length) {

View File

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