From 4c9b6d24c683e917bc40fabd4c52e24e4cf394e3 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sat, 27 Jul 2024 11:35:52 -0700 Subject: [PATCH] LwIpIntfDev.end() check _started to prevent crash From @JAndrassy https://github.com/esp8266/Arduino/pull/9173 --- libraries/lwIP_Ethernet/src/LwipIntfDev.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/lwIP_Ethernet/src/LwipIntfDev.h b/libraries/lwIP_Ethernet/src/LwipIntfDev.h index d90a15710..a6756f43c 100644 --- a/libraries/lwIP_Ethernet/src/LwipIntfDev.h +++ b/libraries/lwIP_Ethernet/src/LwipIntfDev.h @@ -427,18 +427,20 @@ bool LwipIntfDev::begin(const uint8_t* macAddress, const uint16_t mtu) { template void LwipIntfDev::end() { - if (_intrPin < 0) { - __removeEthernetPacketHandler(_phID); - } else { - detachInterrupt(_intrPin); - __removeEthernetGPIO(_intrPin); - } + if (_started) { + if (_intrPin < 0) { + __removeEthernetPacketHandler(_phID); + } else { + detachInterrupt(_intrPin); + __removeEthernetGPIO(_intrPin); + } - RawDev::end(); + RawDev::end(); - netif_remove(&_netif); + netif_remove(&_netif); - _started = false; + _started = false; + } } template