Add check for self-assignment

pull/1115/head
jgromes 2024-05-26 09:25:13 +02:00
rodzic a5e2e58c36
commit 9a9e04d047
3 zmienionych plików z 24 dodań i 18 usunięć

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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);
}