diff --git a/components/detournavigator/navmeshtilescache.cpp b/components/detournavigator/navmeshtilescache.cpp index f554cd4143..cff93ac0e5 100644 --- a/components/detournavigator/navmeshtilescache.cpp +++ b/components/detournavigator/navmeshtilescache.cpp @@ -21,19 +21,32 @@ namespace DetourNavigator std::vector result(indicesSize + verticesSize + areaTypesSize + waterSize + offMeshConnectionsSize); unsigned char* dst = result.data(); - std::memcpy(dst, recastMesh.getIndices().data(), indicesSize); - dst += indicesSize; + if (indicesSize > 0) + { + std::memcpy(dst, recastMesh.getIndices().data(), indicesSize); + dst += indicesSize; + } - std::memcpy(dst, recastMesh.getVertices().data(), verticesSize); - dst += verticesSize; + if (verticesSize > 0) + { + std::memcpy(dst, recastMesh.getVertices().data(), verticesSize); + dst += verticesSize; + } - std::memcpy(dst, recastMesh.getAreaTypes().data(), areaTypesSize); - dst += areaTypesSize; + if (areaTypesSize > 0) + { + std::memcpy(dst, recastMesh.getAreaTypes().data(), areaTypesSize); + dst += areaTypesSize; + } - std::memcpy(dst, recastMesh.getWater().data(), waterSize); - dst += waterSize; + if (waterSize > 0) + { + std::memcpy(dst, recastMesh.getWater().data(), waterSize); + dst += waterSize; + } - std::memcpy(dst, offMeshConnections.data(), offMeshConnectionsSize); + if (offMeshConnectionsSize > 0) + std::memcpy(dst, offMeshConnections.data(), offMeshConnectionsSize); return result; }