diff --git a/lib/klv.js b/lib/klv.js index e8123ae..32ed5f5 100644 --- a/lib/klv.js +++ b/lib/klv.js @@ -61,6 +61,7 @@ KLVStream.prototype.write = function(data) { // Emit the length else if (this.state === KLV_STATES.LENGTH) { var decodedBER = decodeBER(this.buffer); + if (typeof decodedBER.value === 'undefined') { return true; } this.buffer = this.buffer.slice(decodedBER.bytesRead); this.state = KLV_STATES.VALUE; this.valueLength = decodedBER.value; // Record to track the value