mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00: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:
		
				
					committed by
					
						
						Dave Conway-Jones
					
				
			
			
				
	
			
			
			
						parent
						
							eef59fd40e
						
					
				
				
					commit
					5f5aa0b2f7
				
			@@ -492,14 +492,16 @@ module.exports = function(RED) {
 | 
				
			|||||||
                                buf[i] = data[j];
 | 
					                                buf[i] = data[j];
 | 
				
			||||||
                                i += 1;
 | 
					                                i += 1;
 | 
				
			||||||
                                if ( i >= node.splitc) {
 | 
					                                if ( i >= node.splitc) {
 | 
				
			||||||
                                    clients[connection_id].msg.payload = new Buffer(i);
 | 
					                                    if (clients[connection_id]) {
 | 
				
			||||||
                                    buf.copy(clients[connection_id].msg.payload,0,0,i);
 | 
					                                        clients[connection_id].msg.payload = new Buffer(i);
 | 
				
			||||||
                                    node.send(clients[connection_id].msg);
 | 
					                                        buf.copy(clients[connection_id].msg.payload,0,0,i);
 | 
				
			||||||
                                    if (clients[connection_id].client) {
 | 
					                                        node.send(clients[connection_id].msg);
 | 
				
			||||||
                                        node.status({}); clients[connection_id].client.destroy();
 | 
					                                        if (clients[connection_id].client) {
 | 
				
			||||||
                                        delete clients[connection_id];
 | 
					                                            node.status({}); clients[connection_id].client.destroy();
 | 
				
			||||||
 | 
					                                            delete clients[connection_id];
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                        i = 0;
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                                    i = 0;
 | 
					 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            // look for a char
 | 
					                            // look for a char
 | 
				
			||||||
@@ -507,14 +509,16 @@ module.exports = function(RED) {
 | 
				
			|||||||
                                buf[i] = data[j];
 | 
					                                buf[i] = data[j];
 | 
				
			||||||
                                i += 1;
 | 
					                                i += 1;
 | 
				
			||||||
                                if (data[j] == node.splitc) {
 | 
					                                if (data[j] == node.splitc) {
 | 
				
			||||||
                                    clients[connection_id].msg.payload = new Buffer(i);
 | 
					                                    if (clients[connection_id]) {
 | 
				
			||||||
                                    buf.copy(clients[connection_id].msg.payload,0,0,i);
 | 
					                                        clients[connection_id].msg.payload = new Buffer(i);
 | 
				
			||||||
                                    node.send(clients[connection_id].msg);
 | 
					                                        buf.copy(clients[connection_id].msg.payload,0,0,i);
 | 
				
			||||||
                                    if (clients[connection_id].client) {
 | 
					                                        node.send(clients[connection_id].msg);
 | 
				
			||||||
                                        node.status({}); clients[connection_id].client.destroy();
 | 
					                                        if (clients[connection_id].client) {
 | 
				
			||||||
                                        delete clients[connection_id];
 | 
					                                            node.status({}); clients[connection_id].client.destroy();
 | 
				
			||||||
 | 
					                                            delete clients[connection_id];
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                        i = 0;
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                                    i = 0;
 | 
					 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
@@ -560,7 +564,9 @@ module.exports = function(RED) {
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                clients[connection_id].client.write(clients[connection_id].msg.payload);
 | 
					                if (clients[connection_id] && clients[connection_id].client) {
 | 
				
			||||||
 | 
					                    clients[connection_id].client.write(clients[connection_id].msg.payload);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user