From f1782d73e5d6e943d0d75ded07fb7cb7cac6115b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 21 Mar 2021 14:39:31 +0100 Subject: [PATCH] physics: Fix crash in PhysicsNode::add_physicals_from() --- panda/src/physics/physicalNode.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index bda2dd9140..18858b6201 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -72,13 +72,12 @@ make_copy() const { */ void PhysicalNode:: add_physicals_from(const PhysicalNode &other) { - pvector< PT(Physical) >::iterator last = _physicals.end() - 1; - + size_t num_physicals = _physicals.size(); _physicals.insert(_physicals.end(), other._physicals.begin(), other._physicals.end()); - for (; last != _physicals.end(); last++) { - (*last)->_physical_node = this; + for (size_t i = num_physicals; i < _physicals.size(); ++i) { + _physicals[i]->_physical_node = this; } }