summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin <iCollin@users.noreply.github.com>2020-05-20 11:28:09 -0700
committerGitHub <noreply@github.com>2020-05-20 14:28:09 -0400
commit42d6654e4293c61441e3c0ca90cb57ccbe3682c5 (patch)
treef1d0557a6538684695a5a319548c32f6497874cf
parentd97eba89a95d9ece139372dd41a918f11a85f99f (diff)
downloadsdl_core-42d6654e4293c61441e3c0ca90cb57ccbe3682c5.tar.gz
fix memory error in TcpDevice::IsSameAs (#3386)
-rw-r--r--src/components/transport_manager/src/tcp/tcp_device.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/components/transport_manager/src/tcp/tcp_device.cc b/src/components/transport_manager/src/tcp/tcp_device.cc
index 16abdfc22d..d9bc8aec78 100644
--- a/src/components/transport_manager/src/tcp/tcp_device.cc
+++ b/src/components/transport_manager/src/tcp/tcp_device.cc
@@ -66,9 +66,9 @@ TcpDevice::TcpDevice(const in_addr_t& in_addr,
bool TcpDevice::IsSameAs(const Device* other) const {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Device: " << other);
- const TcpDevice* other_tcp_device = static_cast<const TcpDevice*>(other);
+ const TcpDevice* other_tcp_device = dynamic_cast<const TcpDevice*>(other);
- if (other_tcp_device->in_addr_ == in_addr_) {
+ if (other_tcp_device && other_tcp_device->in_addr_ == in_addr_) {
LOG4CXX_TRACE(
logger_,
"exit with TRUE. Condition: other_tcp_device->in_addr_ == in_addr_");