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

Fix possible byte conversion bug #142

Merged
merged 1 commit into from Apr 14, 2016

Conversation

Projects
None yet
2 participants
@champtar
Contributor

champtar commented Apr 14, 2016

bytes in java are signed, and when you convert them to a
bigger type, like int, java perform what we call sign extension
and FF become FFFFFFFF before you shift (<<),
giving you unexpected result (compared to C)

Found using FindBugs
http://findbugs.sourceforge.net/bugDescriptions.html#BIT_ADD_OF_SIGNED_BYTE
http://findbugs.sourceforge.net/bugDescriptions.html#BIT_IOR_OF_SIGNED_BYTE

Signed-off-by: Etienne CHAMPETIER champetier.etienne@gmail.com

Fix possible byte conversion bug
bytes in java are signed, and when you convert them to a
bigger type, like int, java perform what we call sign extension
and FF become FFFFFFFF before you shift (<<),
giving you unexpected result (compared to C)

Found using FindBugs
http://findbugs.sourceforge.net/bugDescriptions.html#BIT_ADD_OF_SIGNED_BYTE
http://findbugs.sourceforge.net/bugDescriptions.html#BIT_IOR_OF_SIGNED_BYTE

Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>

@bgrozev bgrozev merged commit 79fc051 into jitsi:master Apr 14, 2016

1 check failed

default Build finished.
Details

@champtar champtar deleted the champtar:byte_bug branch Apr 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment