Skip to content

Commit

Permalink
Fix upcasting issue that might result in bad hash codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehrmann authored and gtoubassi committed Dec 26, 2012
1 parent 64e3310 commit b434927
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public PrefixHash(byte[] buf, boolean addToHash) {
}

private int hashIndex(byte[] buf, int i) {
int code = buf[i] | (buf[i + 1] << 8) | (buf[i + 2] << 16) | (buf[i + 3] << 24);
int code = (buf[i] & 0xff) | ((buf[i + 1] & 0xff) << 8) | ((buf[i + 2] & 0xff) << 16) | ((buf[i + 3] & 0xff) << 24);
return (code & 0x7fffff) % hash.length;
}

Expand Down

0 comments on commit b434927

Please sign in to comment.