From 9cd943264ebc52a239d8a08469fb94eb8a18d3c5 Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Thu, 18 Mar 2010 08:53:45 +0000 Subject: [PATCH] fixes for Issue 56: Fairly minor bugs picked up by static analysis tool --- DebugUtils/Source/RecastDump.cpp | 2 +- Detour/Source/DetourNavMeshBuilder.cpp | 3 + Recast/Source/RecastMeshDetail.cpp | 6 +- .../Xcode/Recast.xcodeproj/memon.pbxuser | 62 ++++++++++++++++--- .../Recast.xcodeproj/memon.perspectivev3 | 17 ++--- 5 files changed, 68 insertions(+), 22 deletions(-) diff --git a/DebugUtils/Source/RecastDump.cpp b/DebugUtils/Source/RecastDump.cpp index a13afc9..3a8ec42 100644 --- a/DebugUtils/Source/RecastDump.cpp +++ b/DebugUtils/Source/RecastDump.cpp @@ -137,7 +137,7 @@ bool duDumpCompactHeightfield(struct rcCompactHeightfield& chf, const char* file fwrite(&chf.cs, sizeof(chf.cs), 1, fp); fwrite(&chf.ch, sizeof(chf.ch), 1, fp); - int tmp; + int tmp = 0; if (chf.cells) tmp |= 1; if (chf.spans) tmp |= 2; if (chf.dist) tmp |= 4; diff --git a/Detour/Source/DetourNavMeshBuilder.cpp b/Detour/Source/DetourNavMeshBuilder.cpp index f591652..0c0e15e 100644 --- a/Detour/Source/DetourNavMeshBuilder.cpp +++ b/Detour/Source/DetourNavMeshBuilder.cpp @@ -348,7 +348,10 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData, unsigned char* data = new unsigned char[dataSize]; if (!data) + { + delete [] offMeshConClass; return false; + } memset(data, 0, dataSize); unsigned char* d = data; diff --git a/Recast/Source/RecastMeshDetail.cpp b/Recast/Source/RecastMeshDetail.cpp index 0eb3b55..0bef931 100644 --- a/Recast/Source/RecastMeshDetail.cpp +++ b/Recast/Source/RecastMeshDetail.cpp @@ -31,7 +31,7 @@ static const unsigned RC_UNSET_HEIGHT = 0xffff; struct rcHeightPatch { - inline rcHeightPatch() : data(0) {} + inline rcHeightPatch() : data(0), xmin(0), ymin(0), width(0), height(0) {} inline ~rcHeightPatch() { delete [] data; } unsigned short* data; int xmin, ymin, width, height; @@ -770,15 +770,13 @@ static void getHeightData(const rcCompactHeightfield& chf, } // Find center of the polygon using flood fill. - int pcx = 0, pcy = 0, pcz = 0; + int pcx = 0, pcz = 0; for (int j = 0; j < npoly; ++j) { pcx += (int)verts[poly[j]*3+0]; - pcy += (int)verts[poly[j]*3+1]; pcz += (int)verts[poly[j]*3+2]; } pcx /= npoly; - pcy /= npoly; pcz /= npoly; for (int i = 0; i < stack.size(); i += 3) diff --git a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser index 464655d..501b5bd 100644 --- a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser +++ b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser @@ -316,6 +316,10 @@ 6B904C72115218D800A12E63 /* PBXTextBookmark */ = 6B904C72115218D800A12E63 /* PBXTextBookmark */; 6B904C7411521CEA00A12E63 /* PBXTextBookmark */ = 6B904C7411521CEA00A12E63 /* PBXTextBookmark */; 6B904C7611521D4400A12E63 /* PBXTextBookmark */ = 6B904C7611521D4400A12E63 /* PBXTextBookmark */; + 6B904C78115220CA00A12E63 /* PBXTextBookmark */ = 6B904C78115220CA00A12E63 /* PBXTextBookmark */; + 6B904C79115220CA00A12E63 /* PBXTextBookmark */ = 6B904C79115220CA00A12E63 /* PBXTextBookmark */; + 6B904C7A115220CA00A12E63 /* PBXTextBookmark */ = 6B904C7A115220CA00A12E63 /* PBXTextBookmark */; + 6B904C7B115220CA00A12E63 /* PBXTextBookmark */ = 6B904C7B115220CA00A12E63 /* PBXTextBookmark */; 6B92D9121140F58200E82EC3 = 6B92D9121140F58200E82EC3 /* PBXTextBookmark */; 6B92D91C1140F5F800E82EC3 = 6B92D91C1140F5F800E82EC3 /* PBXTextBookmark */; 6B92D9411140F84100E82EC3 = 6B92D9411140F84100E82EC3 /* PBXTextBookmark */; @@ -529,8 +533,8 @@ 6B137C870F7FCC1100459200 /* RecastMesh.cpp */ = { uiCtxt = { sepNavIntBoundsRect = "{{0, 0}, {815, 20224}}"; - sepNavSelRange = "{13330, 0}"; - sepNavVisRange = "{12592, 895}"; + sepNavSelRange = "{13018, 15}"; + sepNavVisRange = "{12592, 1011}"; }; }; 6B137C880F7FCC1100459200 /* RecastRasterization.cpp */ = { @@ -646,7 +650,7 @@ fRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; name = "DetourNavMeshBuilder.cpp: 662"; rLen = 0; - rLoc = 19262; + rLoc = 19297; rType = 0; vrLen = 586; vrLoc = 18880; @@ -1188,9 +1192,9 @@ }; 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {845, 10816}}"; - sepNavSelRange = "{5578, 0}"; - sepNavVisRange = "{5022, 813}"; + sepNavIntBoundsRect = "{{0, 0}, {845, 11056}}"; + sepNavSelRange = "{9737, 0}"; + sepNavVisRange = "{14436, 1054}"; }; }; 6B8DE88B10B69E4C00DF20FB /* DetourNavMesh.h */ = { @@ -2036,7 +2040,7 @@ fRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; name = "DetourNavMeshBuilder.cpp: 662"; rLen = 0; - rLoc = 19262; + rLoc = 19297; rType = 0; vrLen = 646; vrLoc = 18878; @@ -2076,7 +2080,7 @@ fRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; name = "DetourNavMeshBuilder.cpp: 662"; rLen = 0; - rLoc = 19262; + rLoc = 19297; rType = 0; vrLen = 646; vrLoc = 18878; @@ -2708,6 +2712,46 @@ vrLen = 895; vrLoc = 12592; }; + 6B904C78115220CA00A12E63 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 6B137C870F7FCC1100459200 /* RecastMesh.cpp */; + name = "RecastMesh.cpp: 503"; + rLen = 15; + rLoc = 13018; + rType = 0; + vrLen = 1011; + vrLoc = 12592; + }; + 6B904C79115220CA00A12E63 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; + name = "DetourNavMeshBuilder.cpp: 218"; + rLen = 0; + rLoc = 5578; + rType = 0; + vrLen = 899; + vrLoc = 4979; + }; + 6B904C7A115220CA00A12E63 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 6B137C870F7FCC1100459200 /* RecastMesh.cpp */; + name = "RecastMesh.cpp: 503"; + rLen = 15; + rLoc = 13018; + rType = 0; + vrLen = 1011; + vrLoc = 12592; + }; + 6B904C7B115220CA00A12E63 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; + name = "DetourNavMeshBuilder.cpp: 352"; + rLen = 0; + rLoc = 9737; + rType = 0; + vrLen = 1054; + vrLoc = 14436; + }; 6B92D9121140F58200E82EC3 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 6B137C830F7FCC1100459200 /* RecastContour.cpp */; @@ -3441,7 +3485,7 @@ fRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; name = "DetourNavMeshBuilder.cpp: 575"; rLen = 0; - rLoc = 16574; + rLoc = 16609; rType = 0; vrLen = 803; vrLoc = 15718; diff --git a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 index ed8438e..18a0931 100644 --- a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 +++ b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 @@ -281,14 +281,14 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 33 - 21 + 16 + 12 1 0 PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 347}, {358, 643}} + {{0, 178}, {358, 643}} PBXTopSmartGroupGIDs @@ -323,7 +323,7 @@ PBXProjectModuleGUID 6B8632A30F78115100E2684A PBXProjectModuleLabel - RecastMesh.cpp + DetourNavMeshBuilder.cpp PBXSplitModuleInNavigatorKey Split0 @@ -331,11 +331,11 @@ PBXProjectModuleGUID 6B8632A40F78115100E2684A PBXProjectModuleLabel - RecastMesh.cpp + DetourNavMeshBuilder.cpp _historyCapacity 0 bookmark - 6B904C7611521D4400A12E63 + 6B904C7B115220CA00A12E63 history 6B8DE70D10B01BBF00DF20FB @@ -392,7 +392,6 @@ 6B904BB61144F49D00A12E63 6B904BBE1144F50500A12E63 6B904BD01144FCF000A12E63 - 6B904BE91144FDC900A12E63 6B904C091145340E00A12E63 6B904C40115211FB00A12E63 6B904C41115211FB00A12E63 @@ -401,7 +400,8 @@ 6B904C631152164400A12E63 6B904C641152164400A12E63 6B904C6F115218D800A12E63 - 6B904C70115218D800A12E63 + 6B904C78115220CA00A12E63 + 6B904C79115220CA00A12E63 prevStack @@ -488,6 +488,7 @@ 6B904C6B1152164400A12E63 6B904C6C1152164400A12E63 6B904C71115218D800A12E63 + 6B904C7A115220CA00A12E63 SplitCount