From 62fd404f72f63789b4770330c35d6cc8387d548f Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Wed, 1 Jun 2022 21:02:23 -0700 Subject: [PATCH] Move insertion into parts vector to end of lambda to avoid dereferencing real_mount after it has been invalidated. --- src/vehicle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 63ecb1c936ec6..26c5b2bc62a07 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -5894,9 +5894,9 @@ void vehicle::refresh( const bool remove_fakes ) int fake_index = parts.size(); part_real.fake_part_at = fake_index; fake_parts.push_back( fake_index ); - parts.push_back( part_fake ); relative_parts[ part_fake.mount ].push_back( fake_index ); edges.emplace( real_mount, edge_info ); + parts.push_back( part_fake ); } }; // re-install fake parts - this could be done in a separate function, but we want to