From 913b09570c242c6ec17b7b88e91e42064c075c58 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 10 Apr 2016 12:21:56 +0100 Subject: [PATCH] ensure tcp node creates a buffer of size 1 at least --- nodes/core/io/31-tcpin.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 96ef580af..5420af297 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -396,7 +396,10 @@ module.exports = function(RED) { else { this.splitc = this.splitc.replace("\\n",0x0A).replace("\\r",0x0D).replace("\\t",0x09).replace("\\e",0x1B).replace("\\f",0x0C).replace("\\0",0x00); } // jshint ignore:line var buf; - if (this.out == "count") { buf = new Buffer(this.splitc); } + if (this.out == "count") { + if (this.splitc === 0) { buf = new Buffer(1); } + else { buf = new Buffer(this.splitc); } + } else { buf = new Buffer(65536); } // set it to 64k... hopefully big enough for most TCP packets.... but only hopefully this.connected = false; @@ -437,7 +440,7 @@ module.exports = function(RED) { } else { for (var j = 0; j < data.length; j++ ) { - if (node.out === "time") { + if (node.out === "time") { // do the timer thing if (node.tout) { i += 1; @@ -523,7 +526,6 @@ module.exports = function(RED) { this.on("close", function(done) { node.done = done; if (client) { - buf = null; client.destroy(); } node.status({});