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 d939004bbd)
This commit is contained in:
Jon Evans 2024-02-25 08:46:45 -05:00
parent 74339e9a9f
commit 46555ab975
1 changed files with 5 additions and 0 deletions

View File

@ -3053,6 +3053,11 @@ void SCH_IO_ALTIUM::ParsePowerPort( const std::map<wxString, wxString>& 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 );