From 2af3c22d07472a54bf113aa21a34b2e5db83d5d0 Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr." Date: Wed, 15 May 2013 14:00:06 -0400 Subject: [PATCH] [Coverity] Dereference before null check (REVERSE_INULL) --- src/core/model/test.cc | 2 +- src/olsr/model/olsr-routing-protocol.cc | 2 +- src/wimax/model/wimax-tlv.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 47ee7bc4f..91b6afcd4 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -278,7 +278,7 @@ TestCase::CreateDataDirFilename (std::string filename) { NS_LOG_FUNCTION (this << filename); const TestCase *current = this; - while (current->m_dataDir == "" && current != 0) + while (current != 0 && current->m_dataDir == "") { current = current->m_parent; } diff --git a/src/olsr/model/olsr-routing-protocol.cc b/src/olsr/model/olsr-routing-protocol.cc index c1c0a2634..8e9d497f8 100644 --- a/src/olsr/model/olsr-routing-protocol.cc +++ b/src/olsr/model/olsr-routing-protocol.cc @@ -2104,7 +2104,7 @@ RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg, } // Schedules link tuple deletion - if (created && link_tuple != NULL) + if (created) { LinkTupleAdded (*link_tuple, hello.willingness); m_events.Track (Simulator::Schedule (DELAY (std::min (link_tuple->time, link_tuple->symTime)), diff --git a/src/wimax/model/wimax-tlv.cc b/src/wimax/model/wimax-tlv.cc index 48a470e0f..16230489f 100644 --- a/src/wimax/model/wimax-tlv.cc +++ b/src/wimax/model/wimax-tlv.cc @@ -940,9 +940,9 @@ ProtocolTlvValue::ProtocolTlvValue () } ProtocolTlvValue::~ProtocolTlvValue () { - m_protocol->clear (); if (m_protocol != 0) { + m_protocol->clear (); delete m_protocol; m_protocol = 0; } @@ -1013,9 +1013,9 @@ Ipv4AddressTlvValue::Ipv4AddressTlvValue () Ipv4AddressTlvValue::~Ipv4AddressTlvValue () { - m_ipv4Addr->clear (); if (m_ipv4Addr != 0) { + m_ipv4Addr->clear (); delete m_ipv4Addr; m_ipv4Addr = 0; }