Skip to content

Commit

Permalink
Fixed deserialization of variable-length data types (JSON) (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Nov 20, 2016
1 parent 24f4cae commit 1612ebe
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -934,13 +934,15 @@ protected BigInteger readUInt64() throws IOException {
* @return the integer value
*/
protected int readVariableInt() throws IOException {
byte b = 0;
int length = 0;
do {
b = (byte) reader.read();
length = (length << 7) + (b & 0x7F);
} while (b < 0);
return length;
for (int i = 0; i < 5; i++) {
byte b = (byte) reader.read();
length |= (b & 0x7F) << (7 * i);
if ((b & 0x80) == 0) {
return length;
}
}
throw new IOException("Unexpected byte sequence (" + length + ")");
}

protected Boolean readLiteral() throws IOException {
Expand Down

0 comments on commit 1612ebe

Please sign in to comment.