diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp
index 892f9c2dd2..3f133f5033 100644
--- a/components/detournavigator/makenavmesh.cpp
+++ b/components/detournavigator/makenavmesh.cpp
@@ -495,6 +495,10 @@ namespace DetourNavigator
         params.maxPolys = 1 << polysBits;
 
         NavMeshPtr navMesh(dtAllocNavMesh(), &dtFreeNavMesh);
+
+        if (navMesh == nullptr)
+            throw NavigatorException("Failed to allocate navmesh");
+
         const auto status = navMesh->init(&params);
 
         if (!dtStatusSucceed(status))
diff --git a/components/detournavigator/navmeshdata.hpp b/components/detournavigator/navmeshdata.hpp
index 501e971cba..6e400af3bc 100644
--- a/components/detournavigator/navmeshdata.hpp
+++ b/components/detournavigator/navmeshdata.hpp
@@ -20,7 +20,7 @@ namespace DetourNavigator
     struct NavMeshData
     {
         NavMeshDataValue mValue;
-        int mSize;
+        int mSize = 0;
 
         NavMeshData() = default;
 
diff --git a/components/detournavigator/navmeshtilescache.cpp b/components/detournavigator/navmeshtilescache.cpp
index 4710a0a4f6..3d595f13a8 100644
--- a/components/detournavigator/navmeshtilescache.cpp
+++ b/components/detournavigator/navmeshtilescache.cpp
@@ -85,7 +85,8 @@ namespace DetourNavigator
         out.setAttribute(frameNumber, "NavMesh CacheSize", stats.mNavMeshCacheSize);
         out.setAttribute(frameNumber, "NavMesh UsedTiles", stats.mUsedNavMeshTiles);
         out.setAttribute(frameNumber, "NavMesh CachedTiles", stats.mCachedNavMeshTiles);
-        out.setAttribute(frameNumber, "NavMesh CacheHitRate", static_cast<double>(stats.mHitCount) / stats.mGetCount * 100.0);
+        if (stats.mGetCount > 0)
+            out.setAttribute(frameNumber, "NavMesh CacheHitRate", static_cast<double>(stats.mHitCount) / stats.mGetCount * 100.0);
     }
 
     void NavMeshTilesCache::removeLeastRecentlyUsed()