From fcf3ca0568eb8cc0d0167c79db454572165da3f7 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 9 Jun 2024 14:05:54 -0400 Subject: [PATCH] Replace varint assert with exception (#146) --- src/datatypes/utils.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/datatypes/utils.js b/src/datatypes/utils.js index cbd59a3..8cc1d52 100644 --- a/src/datatypes/utils.js +++ b/src/datatypes/utils.js @@ -1,5 +1,3 @@ -const assert = require('assert') - const { getCount, sendCount, calcCount, PartialReadError } = require('../utils') module.exports = { @@ -77,7 +75,7 @@ function readVarInt (buffer, offset) { } } shift += 7 // we only have 7 bits, MSB being the return-trigger - assert.ok(shift < 64, 'varint is too big') // Make sure our shift don't overflow. + if (shift > 64) throw new PartialReadError(`varint is too big: ${shift}`) // Make sure our shift don't overflow. } }