From 14304b7d7508a3639494b450b6abf1cf60328477 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Wed, 26 Apr 2023 19:46:04 -0500 Subject: [PATCH] [evmasm::Assembly] Fix SourceLocation::sourceName shared_ptr creation. --- libevmasm/Assembly.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 034b66bd5..96cd792aa 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -173,7 +173,12 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std: solRequire(srcIndex >= -1 && srcIndex < static_cast(_sourceList.size()), AssemblyImportException, "srcIndex out of bound."); if (srcIndex != -1) - location.sourceName = std::make_shared(_sourceList[static_cast(srcIndex)]); + { + static map> sharedSourceNames; + if (sharedSourceNames.find(_sourceList[static_cast(srcIndex)]) == sharedSourceNames.end()) + sharedSourceNames[_sourceList[static_cast(srcIndex)]] = std::make_shared(_sourceList[static_cast(srcIndex)]); + location.sourceName = sharedSourceNames[_sourceList[static_cast(srcIndex)]]; + } AssemblyItem result(0);