Merge branch 'fix_ubsan_issues' into 'master'

Fix UBSAN issues

See merge request OpenMW/openmw!528
cherry-pick-c431f31c
Alexei Dobrohotov 4 years ago
commit ef852b2c8f

@ -21,19 +21,32 @@ namespace DetourNavigator
std::vector<unsigned char> 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;
}

@ -25,7 +25,7 @@ void ESM::SavedGame::load (ESMReader &esm)
esm.getSubNameIs("SCRN");
esm.getSubHeader();
mScreenshot.resize(esm.getSubSize());
esm.getExact(&mScreenshot[0], mScreenshot.size());
esm.getExact(mScreenshot.data(), mScreenshot.size());
}
void ESM::SavedGame::save (ESMWriter &esm) const

Loading…
Cancel
Save