这是indexloc提供的服务,不要输入任何密码
Skip to content

encode bug #3

@dchack

Description

@dchack

there is a bug, please check it.
byte[] encode = PomeloPackage.encode(PomeloPackage.TYPE_DATA, bytes);
in the function encode:
public static byte[] encode(int type, byte[] body) {
int length = body != null ? body.length : 0;
byte[] buffer = new byte[PKG_HEAD_BYTES + length];
int index = 0;
buffer[index++] = (byte) (type);
buffer[index++] = (byte) ((length >> 16));
buffer[index++] = (byte) ((length >> 8));
buffer[index++] = (byte) (length);
if (body != null) {
for (byte i = 0; i < body.length; i++) {
buffer[PKG_HEAD_BYTES + i] = (byte) body[i];
}
}
return buffer;
}

body.length is bigger then 128, in for(...),i is a byte type ,so there is a Exception :java.lang.ArrayIndexOutOfBoundsException: -128

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions