1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Avoid possible null dereference

This commit is contained in:
Andrei Kortunov 2022-07-12 12:56:53 +04:00
parent 42b9a6daaf
commit a5b0ef0912
2 changed files with 4 additions and 2 deletions

View File

@ -230,7 +230,8 @@ namespace CSMWorld
for (int i=0; i<size; ++i)
{
buffer[newOrder[i]] = std::move(mRecords [baseIndex+i]);
buffer[newOrder[i]]->setModified (buffer[newOrder[i]]->get());
if (buffer[newOrder[i]])
buffer[newOrder[i]]->setModified (buffer[newOrder[i]]->get());
}
std::move (buffer.begin(), buffer.end(), mRecords.begin()+baseIndex);

View File

@ -58,7 +58,8 @@ namespace CSMWorld
for (int i = 0; i < size; ++i)
{
buffer[newOrder[i]] = std::move(mRecords[baseIndex+i]);
buffer[newOrder[i]]->setModified(buffer[newOrder[i]]->get());
if (buffer[newOrder[i]])
buffer[newOrder[i]]->setModified(buffer[newOrder[i]]->get());
}
std::move(buffer.begin(), buffer.end(), mRecords.begin()+baseIndex);