From 0a47e623fd155a127351af53a88a4502e1c61e74 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 7 Mar 2020 03:56:12 -0500 Subject: [PATCH] CResFactory: Resolve use-after-move in AddToLoadList() The behavior on the right hand side would occur before the actual assignment, making the tag value invalidated. Instead, we copy the tag before the move is performed to keep the data valid when inserting it into the map. --- Runtime/CResFactory.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Runtime/CResFactory.cpp b/Runtime/CResFactory.cpp index c2a776ba0..a90a48835 100644 --- a/Runtime/CResFactory.cpp +++ b/Runtime/CResFactory.cpp @@ -7,7 +7,8 @@ namespace urde { static logvisor::Module Log("CResFactory"); void CResFactory::AddToLoadList(SLoadingData&& data) { - m_loadMap[data.x0_tag] = m_loadList.insert(m_loadList.end(), std::move(data)); + const SObjectTag tag = data.x0_tag; + m_loadMap.insert_or_assign(tag, m_loadList.insert(m_loadList.end(), std::move(data))); } CFactoryFnReturn CResFactory::BuildSync(const SObjectTag& tag, const CVParamTransfer& xfer, CObjectReference* selfRef) {