Skip to content

Commit fe9dc91

Browse files
author
Me No Dev
committed
unref udp if exists
1 parent b485a6c commit fe9dc91

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libraries/ArduinoOTA/ArduinoOTA.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ ArduinoOTAClass::ArduinoOTAClass()
3434
{
3535
}
3636

37+
ArduinoOTAClass::~ArduinoOTAClass(){
38+
if(_udp_ota){
39+
_udp_ota->unref();
40+
_udp_ota = 0;
41+
}
42+
}
43+
3744
void ArduinoOTAClass::onStart(OTA_CALLBACK(fn)) {
3845
_start_callback = fn;
3946
}
@@ -50,9 +57,6 @@ void ArduinoOTAClass::onError(OTA_CALLBACK_ERROR(fn)) {
5057
_error_callback = fn;
5158
}
5259

53-
ArduinoOTAClass::~ArduinoOTAClass() {
54-
}
55-
5660
void ArduinoOTAClass::setPort(uint16_t port) {
5761
if (!_initialized && !_port && port) {
5862
_port = port;
@@ -84,6 +88,11 @@ void ArduinoOTAClass::begin() {
8488
_port = 8266;
8589
}
8690

91+
if(_udp_ota){
92+
_udp_ota->unref();
93+
_udp_ota = 0;
94+
}
95+
8796
_udp_ota = new UdpContext;
8897
_udp_ota->ref();
8998

0 commit comments

Comments
 (0)