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:
parent
d5eb265f78
commit
b3b9276bf9
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user