gmag11 / ESPNtpClient

High accuracy NTP library for ESP32 and ESP8266
MIT License
118 stars 25 forks source link

NTP.stop() does not clear the UDP object properly #53

Open naomai opened 5 months ago

naomai commented 5 months ago

When calling NTP.begin() on client that was previously stopped with NTP.stop(), the device crashes.

NTPClient::stop only deallocates udp handle using udp_remove, but the pointer is not set to NULL. https://github.com/gmag11/ESPNtpClient/blob/2666fd83941569cb5cc426800e5b62f64f17fbac/src/ESPNtpClient.h#L400-L402

This causes the subsequent NTPClient::begin call to crash because of calling udp functions on deallocated udp_pcb https://github.com/gmag11/ESPNtpClient/blob/2666fd83941569cb5cc426800e5b62f64f17fbac/src/ESPNtpClient.cpp#L174-L179

Thanks for creating a really helpful library! Tomasz