From e4791becd5655c7c716f6656335d80d3b0fbc3fa Mon Sep 17 00:00:00 2001 From: Ben Hymers Date: Sun, 13 Mar 2016 23:20:05 +0000 Subject: [PATCH] Fix Coverity warning about odd null check in TempObstacleHilightTool m_sample was being checked for null after being used, which looks like a null dereference, though actually if m_sample becomes null, the tool will be deactivated anyway. Regardless, this code looks more sensible. --- RecastDemo/Source/Sample_TempObstacles.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/RecastDemo/Source/Sample_TempObstacles.cpp b/RecastDemo/Source/Sample_TempObstacles.cpp index a109d1b..c523b7c 100644 --- a/RecastDemo/Source/Sample_TempObstacles.cpp +++ b/RecastDemo/Source/Sample_TempObstacles.cpp @@ -726,7 +726,7 @@ public: virtual void handleRender() { - if (m_hitPosSet) + if (m_hitPosSet && m_sample) { const float s = m_sample->getAgentRadius(); glColor4ub(0,0,0,128); @@ -740,14 +740,10 @@ public: glVertex3f(m_hitPos[0],m_hitPos[1]+0.1f,m_hitPos[2]+s); glEnd(); glLineWidth(1.0f); - - if (m_sample) - { - int tx=0, ty=0; - m_sample->getTilePos(m_hitPos, tx, ty); - m_sample->renderCachedTile(tx,ty,m_drawType); - } + int tx=0, ty=0; + m_sample->getTilePos(m_hitPos, tx, ty); + m_sample->renderCachedTile(tx,ty,m_drawType); } }