From 5a00978b1bcda0118ed9f369bc0d83b9f509a934 Mon Sep 17 00:00:00 2001 From: Dominic Tarr Date: Mon, 26 May 2014 18:11:56 +0200 Subject: [PATCH] instead of throwing, return undefined in invalid (too short) buffers --- decode.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/decode.js b/decode.js index 6269e73..25605aa 100644 --- a/decode.js +++ b/decode.js @@ -18,7 +18,12 @@ function read(buf, offset) { shift += 7 } while (b >= MSB) - read.bytesRead = counter - offset + if(b === undefined) { + read.bytesRead = 0 + res = undefined + } + else + read.bytesRead = counter - offset return res }