mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
TCPGet: Last property check (hopefully) (#1059)
* Add additional safety checks to avoid acting on non-existent objects * TCPGet: yet more checks
This commit is contained in:
parent
eef59fd40e
commit
5f5aa0b2f7
@ -492,6 +492,7 @@ module.exports = function(RED) {
|
||||
buf[i] = data[j];
|
||||
i += 1;
|
||||
if ( i >= node.splitc) {
|
||||
if (clients[connection_id]) {
|
||||
clients[connection_id].msg.payload = new Buffer(i);
|
||||
buf.copy(clients[connection_id].msg.payload,0,0,i);
|
||||
node.send(clients[connection_id].msg);
|
||||
@ -502,11 +503,13 @@ module.exports = function(RED) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// look for a char
|
||||
else {
|
||||
buf[i] = data[j];
|
||||
i += 1;
|
||||
if (data[j] == node.splitc) {
|
||||
if (clients[connection_id]) {
|
||||
clients[connection_id].msg.payload = new Buffer(i);
|
||||
buf.copy(clients[connection_id].msg.payload,0,0,i);
|
||||
node.send(clients[connection_id].msg);
|
||||
@ -519,6 +522,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
clients[connection_id].client.on('end', function() {
|
||||
@ -560,8 +564,10 @@ module.exports = function(RED) {
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (clients[connection_id] && clients[connection_id].client) {
|
||||
clients[connection_id].client.write(clients[connection_id].msg.payload);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.on("close", function(done) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user