From 398904dffe824ba857e1d1f9c0c64941391a364f Mon Sep 17 00:00:00 2001 From: Andrew Hart Date: Mon, 12 Oct 2015 10:02:34 -0700 Subject: [PATCH] Ensure positive integer input to LEB128 encode function --- lib/protocol/LEB128.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/protocol/LEB128.js b/lib/protocol/LEB128.js index 7d74b71..c26492e 100644 --- a/lib/protocol/LEB128.js +++ b/lib/protocol/LEB128.js @@ -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); - }, /**