From 46555ab97553c0ca9384a00a81ede578587acbb7 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 25 Feb 2024 08:46:45 -0500 Subject: [PATCH] Fix use-after-free in Altium importer If the library already contains a symbol with the same name, SaveSymbol will replace the existing symbol, which will invalidate a cached pointer. (cherry picked from commit d939004bbd8921a95da8e578c2dd891f969bc39b) --- eeschema/sch_io/altium/sch_io_altium.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 95db3e722d..b0df67eb29 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -3053,6 +3053,11 @@ void SCH_IO_ALTIUM::ParsePowerPort( const std::map& aPropert { libSymbol = powerSymbolIt->second; // cache hit } + else if( LIB_SYMBOL* alreadyLoaded = + m_pi->LoadSymbol( getLibFileName().GetFullPath(), elem.text, m_properties.get() ) ) + { + libSymbol = alreadyLoaded; + } else { libSymbol = new LIB_SYMBOL( wxEmptyString );