fix tcp node new Buffer alloc size 0

This commit is contained in:
Dave Conway-Jones 2017-06-27 16:58:01 +01:00
parent aa7fe3668c
commit 4dd2d3ac7d
No known key found for this signature in database
GPG Key ID: 81B04231572A9A2D
1 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ module.exports = function(RED) {
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
var id = (1+Math.random()*4294967295).toString(16);
client = net.connect(node.port, node.host, function() {
buffer = (node.datatype == 'buffer') ? new Buffer.from(0) : "";
buffer = (node.datatype == 'buffer') ? new Buffer.alloc(0) : "";
node.connected = true;
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
@ -132,7 +132,7 @@ module.exports = function(RED) {
count++;
node.status({text:RED._("tcpin.status.connections",{count:count})});
var buffer = (node.datatype == 'buffer') ? new Buffer.from(0) : "";
var buffer = (node.datatype == 'buffer') ? new Buffer.alloc(0) : "";
socket.on('data', function (data) {
if (node.datatype != 'buffer') {
data = data.toString(node.datatype);