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

Possible bug in UnsafeBuffer putLongAsAscii #145

Closed
eranff opened this issue Jul 3, 2018 · 1 comment
Closed

Possible bug in UnsafeBuffer putLongAsAscii #145

eranff opened this issue Jul 3, 2018 · 1 comment
Labels

Comments

@eranff
Copy link

eranff commented Jul 3, 2018

In the method putLongAsAscii in UnsafeBuffer the code
if (value == Integer.MIN_VALUE)
{
putBytes(index, MIN_LONG_VALUE);
return MIN_LONG_VALUE.length;
}

Should be
if (value == Long.MIN_VALUE)
{
putBytes(index, MIN_LONG_VALUE);
return MIN_LONG_VALUE.length;
}

To reproduce

public static void main(String...args) {
UnsafeBuffer buffer = new UnsafeBuffer(new byte[128]);
System.out.println(Integer.MIN_VALUE);
buffer.putLongAscii(0, Integer.MIN_VALUE);
System.out.println(buffer.getStringWithoutLengthAscii(0, 24));
buffer = new UnsafeBuffer(new byte[128]);
System.out.println(Long.MIN_VALUE);
buffer.putLongAscii(0, Long.MIN_VALUE);
System.out.println(buffer.getStringWithoutLengthAscii(0, 24));
buffer = new UnsafeBuffer(new byte[128]);
System.out.println(Long.MIN_VALUE-1);
buffer.putLongAscii(0, Long.MIN_VALUE-1);
System.out.println(buffer.getStringWithoutLengthAscii(0, 24));
}

@mjpt777 mjpt777 added the bug label Jul 4, 2018
mjpt777 added a commit that referenced this issue Jul 4, 2018
@mjpt777
Copy link
Contributor

mjpt777 commented Jul 4, 2018

Thanks.

@mjpt777 mjpt777 closed this as completed Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants