Fix leak of memory and possible crashes in AsyncUDP
This commit is contained in:
		
							parent
							
								
									f13ff65691
								
							
						
					
					
						commit
						8134a42162
					
				| @ -277,6 +277,16 @@ void AsyncUDPMessage::flush() | |||||||
|     _index = 0; |     _index = 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | AsyncUDPPacket::AsyncUDPPacket(AsyncUDPPacket &packet){ | ||||||
|  |     _udp = packet._udp; | ||||||
|  |     _pb = packet._pb; | ||||||
|  |     _if = packet._if; | ||||||
|  |     _data = packet._data; | ||||||
|  |     _len = packet._len; | ||||||
|  |     _index = 0; | ||||||
|  | 
 | ||||||
|  |     pbuf_ref(_pb); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| AsyncUDPPacket::AsyncUDPPacket(AsyncUDP *udp, pbuf *pb, const ip_addr_t *raddr, uint16_t rport, struct netif * ntif) | AsyncUDPPacket::AsyncUDPPacket(AsyncUDP *udp, pbuf *pb, const ip_addr_t *raddr, uint16_t rport, struct netif * ntif) | ||||||
| { | { | ||||||
| @ -683,9 +693,8 @@ void AsyncUDP::_recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t po | |||||||
|         if(_handler) { |         if(_handler) { | ||||||
|             AsyncUDPPacket packet(this, this_pb, addr, port, netif); |             AsyncUDPPacket packet(this, this_pb, addr, port, netif); | ||||||
|             _handler(packet); |             _handler(packet); | ||||||
|         } else { |  | ||||||
|             pbuf_free(this_pb); |  | ||||||
|         } |         } | ||||||
|  |         pbuf_free(this_pb); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -58,6 +58,7 @@ protected: | |||||||
|     size_t _len; |     size_t _len; | ||||||
|     size_t _index; |     size_t _index; | ||||||
| public: | public: | ||||||
|  |     AsyncUDPPacket(AsyncUDPPacket &packet); | ||||||
|     AsyncUDPPacket(AsyncUDP *udp, pbuf *pb, const ip_addr_t *addr, uint16_t port, struct netif * netif); |     AsyncUDPPacket(AsyncUDP *udp, pbuf *pb, const ip_addr_t *addr, uint16_t port, struct netif * netif); | ||||||
|     virtual ~AsyncUDPPacket(); |     virtual ~AsyncUDPPacket(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user