Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cce70d2

Browse filesBrowse files
richard-simcmaglie
authored andcommitted
* Fixed memory leak when calling Ethernet.begin() multiple times
* Ensure the UDP socket is closed before trying to open it
1 parent 6dbc2bf commit cce70d2
Copy full SHA for cce70d2

File tree

Expand file treeCollapse file tree

2 files changed

+3
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-1
lines changed

‎libraries/Ethernet/Dhcp.cpp

Copy file name to clipboardExpand all lines: libraries/Ethernet/Dhcp.cpp
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ int DhcpClass::request_DHCP_lease(){
4343
_dhcpTransactionId = random(1UL, 2000UL);
4444
_dhcpInitialTransactionId = _dhcpTransactionId;
4545

46+
_dhcpUdpSocket.stop();
4647
if (_dhcpUdpSocket.begin(DHCP_CLIENT_PORT) == 0)
4748
{
4849
// Couldn't get a socket

‎libraries/Ethernet/Ethernet.cpp

Copy file name to clipboardExpand all lines: libraries/Ethernet/Ethernet.cpp
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = {
1010

1111
int EthernetClass::begin(uint8_t *mac_address)
1212
{
13-
_dhcp = new DhcpClass();
13+
static DhcpClass s_dhcp;
14+
_dhcp = &s_dhcp;
1415

1516

1617
// Initialise the basic info

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.