From 6ab3ab44b615111cef1b8081ed623f97f12d68ed Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 20 May 2020 12:49:38 -0400 Subject: fix memory error in TcpDevice::IsSameAs --- src/components/transport_manager/src/tcp/tcp_device.cc | 4 ++-- 1 file 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(other); + const TcpDevice* other_tcp_device = dynamic_cast(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_"); -- cgit v1.2.1