1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

* Fixed memory leak when calling Ethernet.begin() multiple times

* Ensure the UDP socket is closed before trying to open it
This commit is contained in:
Richard Sim 2012-12-02 22:39:34 -08:00 committed by Cristian Maglie
parent 6dbc2bfc57
commit cce70d269c
2 changed files with 3 additions and 1 deletions

View File

@ -43,6 +43,7 @@ int DhcpClass::request_DHCP_lease(){
_dhcpTransactionId = random(1UL, 2000UL); _dhcpTransactionId = random(1UL, 2000UL);
_dhcpInitialTransactionId = _dhcpTransactionId; _dhcpInitialTransactionId = _dhcpTransactionId;
_dhcpUdpSocket.stop();
if (_dhcpUdpSocket.begin(DHCP_CLIENT_PORT) == 0) if (_dhcpUdpSocket.begin(DHCP_CLIENT_PORT) == 0)
{ {
// Couldn't get a socket // Couldn't get a socket

View File

@ -10,7 +10,8 @@ uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = {
int EthernetClass::begin(uint8_t *mac_address) int EthernetClass::begin(uint8_t *mac_address)
{ {
_dhcp = new DhcpClass(); static DhcpClass s_dhcp;
_dhcp = &s_dhcp;
// Initialise the basic info // Initialise the basic info