mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-10 09:18:19 +00:00
fix: UB with LivingEntities::pushEntities
This commit is contained in:
parent
76788f1708
commit
f7e555ea6b
|
|
@ -485,7 +485,7 @@ File Minecraft::getWorkingDirectory(const std::string& applicationName) {
|
|||
|
||||
return workingDirectory;
|
||||
} else {
|
||||
Log::info("Could not locate user's home directory. This platform is likely missing an implementation of Minecraft::getWorkingDirectory.");
|
||||
Log::info("Could not locate user's home directory. This platform is likely missing an implementation of Minecraft::getWorkingDirectory.\n");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1604,11 +1604,15 @@ void LivingEntity::pushEntities() {
|
|||
AABB grown = bb.grow(0.2, 0, 0.2);
|
||||
std::vector<std::shared_ptr<Entity>>* entities =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
if (entities != nullptr && !entities->empty()) {
|
||||
auto itEnd = entities->end();
|
||||
for (auto it = entities->begin(); it != itEnd; it++) {
|
||||
std::shared_ptr<Entity> e = *it; // entities->at(i);
|
||||
if (e and !e->removed and e->isPushable()) push(e);
|
||||
|
||||
if (entities == nullptr || entities->empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Entity>> prev_entities = *entities;
|
||||
for (const std::shared_ptr<Entity>& e : prev_entities) {
|
||||
if (e && !e->removed && e->isPushable()) {
|
||||
push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue