Skip to content

Commit 98b09d7

Browse files
committed
[lwip/core/dhcp.c]Fixed incorrect pairing of DHCP enable/disable in lwip (≤v2.0.3).
1 parent 138c888 commit 98b09d7

File tree

2 files changed

+15
-6
lines changed
  • components/net/lwip

2 files changed

+15
-6
lines changed

components/net/lwip/lwip-1.4.1/src/core/dhcp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,9 +1735,10 @@ static void
17351735
dhcp_delete_msg(struct dhcp *dhcp)
17361736
{
17371737
LWIP_ERROR("dhcp_delete_msg: dhcp != NULL", (dhcp != NULL), return;);
1738-
LWIP_ASSERT("dhcp_delete_msg: dhcp->p_out != NULL", dhcp->p_out != NULL);
1739-
LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL);
1738+
/* LWIP_ASSERT("dhcp_delete_msg: dhcp->p_out != NULL", dhcp->p_out != NULL); */
1739+
/* LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL); */
17401740
if (dhcp->p_out != NULL) {
1741+
LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL);
17411742
pbuf_free(dhcp->p_out);
17421743
}
17431744
dhcp->p_out = NULL;

components/net/lwip/lwip-2.0.3/src/core/ipv4/dhcp.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,6 @@ dhcp_stop(struct netif *netif)
13581358

13591359
LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL);
13601360
dhcp_set_state(dhcp, DHCP_STATE_OFF);
1361-
13621361
if (dhcp->pcb_allocated != 0) {
13631362
dhcp_dec_pcb_refcount(); /* free DHCP PCB if not needed any more */
13641363
dhcp->pcb_allocated = 0;
@@ -1817,7 +1816,15 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type)
18171816
xid = DHCP_GLOBAL_XID;
18181817
xid_initialised = !xid_initialised;
18191818
}
1820-
#endif
1819+
#endif
1820+
1821+
/* Clear any existing message before creating a new one */
1822+
if (dhcp->p_out != NULL) {
1823+
pbuf_free(dhcp->p_out);
1824+
dhcp->p_out = NULL;
1825+
dhcp->msg_out = NULL;
1826+
}
1827+
18211828
LWIP_ERROR("dhcp_create_msg: netif != NULL", (netif != NULL), return ERR_ARG;);
18221829
LWIP_ERROR("dhcp_create_msg: dhcp != NULL", (dhcp != NULL), return ERR_VAL;);
18231830
LWIP_ASSERT("dhcp_create_msg: dhcp->p_out == NULL", dhcp->p_out == NULL);
@@ -1899,9 +1906,10 @@ static void
18991906
dhcp_delete_msg(struct dhcp *dhcp)
19001907
{
19011908
LWIP_ERROR("dhcp_delete_msg: dhcp != NULL", (dhcp != NULL), return;);
1902-
LWIP_ASSERT("dhcp_delete_msg: dhcp->p_out != NULL", dhcp->p_out != NULL);
1903-
LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL);
1909+
/* LWIP_ASSERT("dhcp_delete_msg: dhcp->p_out != NULL", dhcp->p_out != NULL); */
1910+
/* LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL); */
19041911
if (dhcp->p_out != NULL) {
1912+
LWIP_ASSERT("dhcp_delete_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL);
19051913
pbuf_free(dhcp->p_out);
19061914
}
19071915
dhcp->p_out = NULL;

0 commit comments

Comments
 (0)