do not read outside the bounds of the buffer

master
Dominic Tarr 10 years ago
parent 76ce046de9
commit 490e48499d

@ -9,8 +9,13 @@ function read(buf, offset) {
, shift = 0
, counter = offset
, b
, l = buf.length
do {
if(counter >= l) {
read.bytesRead = 0
return undefined
}
b = buf[counter++]
res += shift < 28
? (b & REST) << shift
@ -18,12 +23,7 @@ function read(buf, offset) {
shift += 7
} while (b >= MSB)
if(b === undefined) {
read.bytesRead = 0
res = undefined
}
else
read.bytesRead = counter - offset
read.bytesRead = counter - offset
return res
}

Loading…
Cancel
Save