Browse Source

physics: Fix crash in PhysicsNode::add_physicals_from()

rdb 4 years ago
parent
commit
f1782d73e5
1 changed files with 3 additions and 4 deletions
  1. 3 4
      panda/src/physics/physicalNode.cxx

+ 3 - 4
panda/src/physics/physicalNode.cxx

@@ -72,13 +72,12 @@ make_copy() const {
  */
  */
 void PhysicalNode::
 void PhysicalNode::
 add_physicals_from(const PhysicalNode &other) {
 add_physicals_from(const PhysicalNode &other) {
-  pvector< PT(Physical) >::iterator last = _physicals.end() - 1;
-
+  size_t num_physicals = _physicals.size();
   _physicals.insert(_physicals.end(),
   _physicals.insert(_physicals.end(),
                     other._physicals.begin(), other._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;
   }
   }
 }
 }