From 5829b2064b79b3894150d380cd318a188c7c8ae1 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 30 Sep 2016 02:44:36 -0400 Subject: [PATCH] at least one byte body --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 91e55a1..3b3495e 100644 --- a/index.js +++ b/index.js @@ -142,7 +142,7 @@ module.exports.create = function (opts) { machine.service = machine.service || machine.type; machine.type = machine.type || machine.service; - data = (machine.buf||Buffer.alloc(0)).slice(0, machine.bufIndex); + data = machine.buf.slice(0, machine.bufIndex); // @@ -229,7 +229,10 @@ module.exports.create = function (opts) { }; module.exports.pack = function (address, data, type) { - data = data || Buffer.alloc(0); + data = data || Buffer.alloc(1); + if (!data.byteLength) { + data = Buffer.alloc(1); + } if (type || (data.byteLength <= '|__ERROR__|'.length)) { if ('error' === type || '|__ERROR__|' === data.toString()) { address.type = 'error';