Skip to content

Commit

Permalink
fix nullptr error
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemeowx2 committed Dec 19, 2018
1 parent ffabc55 commit 0e4332b
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions ldn_mitm/source/lan_discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ Result LANDiscovery::createNetwork(const SecurityConfig *securityConfig, const U
}

Result LANDiscovery::destroyNetwork() {
this->tcp->close();
if (this->tcp) {
this->tcp->close();
}
this->resetStations();

this->setState(CommState::AccessPoint);
Expand All @@ -566,8 +568,9 @@ Result LANDiscovery::destroyNetwork() {
}

Result LANDiscovery::disconnect() {
this->tcp->close();

if (this->tcp) {
this->tcp->close();
}
this->setState(CommState::Station);

return 0;
Expand All @@ -578,7 +581,9 @@ Result LANDiscovery::openAccessPoint() {
return MAKERESULT(LdnModuleId, 32);
}

this->tcp->close();
if (this->tcp) {
this->tcp->close();
}
this->resetStations();

this->setState(CommState::AccessPoint);
Expand All @@ -591,7 +596,9 @@ Result LANDiscovery::closeAccessPoint() {
return MAKERESULT(LdnModuleId, 32);
}

this->tcp->close();
if (this->tcp) {
this->tcp->close();
}
this->resetStations();

this->setState(CommState::Initialized);
Expand All @@ -604,7 +611,9 @@ Result LANDiscovery::openStation() {
return MAKERESULT(LdnModuleId, 32);
}

this->tcp->close();
if (this->tcp) {
this->tcp->close();
}
this->resetStations();

this->setState(CommState::Station);
Expand All @@ -617,7 +626,9 @@ Result LANDiscovery::closeStation() {
return MAKERESULT(LdnModuleId, 32);
}

this->tcp->close();
if (this->tcp) {
this->tcp->close();
}
this->resetStations();

this->setState(CommState::Initialized);
Expand Down Expand Up @@ -669,7 +680,7 @@ Result LANDiscovery::finalize() {
this->stop = true;
this->workerThread.Join();
this->udp.reset();
this->tcp->close();
this->tcp.reset();
this->resetStations();
this->inited = false;
}
Expand Down

0 comments on commit 0e4332b

Please sign in to comment.