1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Avoid NPE and "multi-deinitialization" of ArduinoOTA (#9058)

Avoid a null pointer exception when ArduinoOTA.end() is called more than once and thus the UDP socket is already freed.

Also avoid unnecessary teardown if the class is not initialized yet (for example, begin() wasn't called yet, or end() is called multiple times).
This commit is contained in:
Adriano Cunha 2024-01-18 12:26:18 -08:00 committed by GitHub
parent d5eb265f78
commit b3b9276bf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -359,9 +359,14 @@ void ArduinoOTAClass::_runUpdate() {
}
void ArduinoOTAClass::end() {
if (!_initialized)
return;
_initialized = false;
if(_udp_ota){
_udp_ota->unref();
_udp_ota = 0;
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
if(_useMDNS){
MDNS.end();