Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encode bug #3

Open
dchack opened this issue Jan 2, 2014 · 4 comments
Open

encode bug #3

dchack opened this issue Jan 2, 2014 · 4 comments

Comments

@dchack
Copy link

dchack commented Jan 2, 2014

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

@dchack
Copy link
Author

dchack commented Jan 6, 2014

hello Are you here?

@jzsues
Copy link
Owner

jzsues commented Jan 6, 2014

thanks for your report

I will fix this issue soon

@wehtta
Copy link

wehtta commented Nov 3, 2016

wtf!

@wehtta
Copy link

wehtta commented Nov 3, 2016

what the heck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants