Fix crash in sntp.sync() (#3460)

This commit is contained in:
Lukáš Voborský 2021-08-27 12:09:43 +02:00 committed by Nathaniel Wesley Filardo
parent 2ccce2395d
commit 3e97667ff4
1 changed files with 1 additions and 1 deletions

View File

@ -806,7 +806,7 @@ static int sntp_sync (lua_State *L)
} else if (server_count == 0) { } else if (server_count == 0) {
lua_newtable(L); lua_newtable(L);
struct netif *iface = (struct netif *)eagle_lwip_getif(0x00); struct netif *iface = (struct netif *)eagle_lwip_getif(0x00);
if (iface->dhcp && iface->dhcp->offered_ntp_addr.addr) { if (iface && iface->dhcp && iface->dhcp->offered_ntp_addr.addr) {
ip_addr_t ntp_addr = iface->dhcp->offered_ntp_addr; ip_addr_t ntp_addr = iface->dhcp->offered_ntp_addr;
lua_pushinteger(L, 1); lua_pushinteger(L, 1);
lua_pushstring(L, inet_ntoa(ntp_addr)); lua_pushstring(L, inet_ntoa(ntp_addr));