Skip to content

Commit

Permalink
Ensure positive integer input to LEB128 encode function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfhart committed Oct 12, 2015
1 parent 9ffcf69 commit 398904d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/protocol/LEB128.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ var LEB128 = {
**/
encode: function (value) {

if (value < 0) {
throw new Error('Negative values are not supported');
if (parseInt(value) === value && value >= 0) {
return leb.encodeUInt64(value);
} else {
throw new Error('Value to encode must be a positive integer');
}

return leb.encodeUInt64(value);

},

/**
Expand Down

0 comments on commit 398904d

Please sign in to comment.