diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 480ea343..c5913e94 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -214,16 +214,18 @@ AX25Client::AX25Client(const AX25Client& ax25) } AX25Client& AX25Client::operator=(const AX25Client& ax25) { - this->phyLayer = ax25.phyLayer; - this->sourceSSID = ax25.sourceSSID; - this->preambleLen = ax25.preambleLen; - strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1); - #if !RADIOLIB_EXCLUDE_AFSK - if(ax25.bellModem) { - this->audio = ax25.audio; - this->bellModem = new BellClient(ax25.audio); + if(&ax25 != this) { + this->phyLayer = ax25.phyLayer; + this->sourceSSID = ax25.sourceSSID; + this->preambleLen = ax25.preambleLen; + strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1); + #if !RADIOLIB_EXCLUDE_AFSK + if(ax25.bellModem) { + this->audio = ax25.audio; + this->bellModem = new BellClient(ax25.audio); + } + #endif } - #endif return(*this); } diff --git a/src/protocols/ExternalRadio/ExternalRadio.cpp b/src/protocols/ExternalRadio/ExternalRadio.cpp index d8c3a5fa..212f8a15 100644 --- a/src/protocols/ExternalRadio/ExternalRadio.cpp +++ b/src/protocols/ExternalRadio/ExternalRadio.cpp @@ -22,9 +22,11 @@ ExternalRadio::ExternalRadio(const ExternalRadio& ext) : PhysicalLayer(1, 0) { } ExternalRadio& ExternalRadio::operator=(const ExternalRadio& ext) { - this->prevFrf = ext.prevFrf; - if(ext.mod) { - this->mod = new Module(ext.mod->hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, ext.mod->getGpio()); + if(&ext != this) { + this->prevFrf = ext.prevFrf; + if(ext.mod) { + this->mod = new Module(ext.mod->hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, ext.mod->getGpio()); + } } return(*this); } diff --git a/src/protocols/Print/ITA2String.cpp b/src/protocols/Print/ITA2String.cpp index 6c67faa5..368edebf 100644 --- a/src/protocols/Print/ITA2String.cpp +++ b/src/protocols/Print/ITA2String.cpp @@ -30,12 +30,14 @@ ITA2String::ITA2String(const ITA2String& ita2) { } ITA2String& ITA2String::operator=(const ITA2String& ita2) { - this->asciiLen = ita2.asciiLen; - this->ita2Len = ita2.ita2Len; - #if !RADIOLIB_STATIC_ONLY - this->strAscii = new char[asciiLen + 1]; - #endif - strcpy(this->strAscii, ita2.strAscii); + if(&ita2 != this) { + this->asciiLen = ita2.asciiLen; + this->ita2Len = ita2.ita2Len; + #if !RADIOLIB_STATIC_ONLY + this->strAscii = new char[asciiLen + 1]; + #endif + strcpy(this->strAscii, ita2.strAscii); + } return(*this); }