Ensure that we clear deleted values

When throwing on an invalid value, we may end up freeing the same tree
twice.  This is generally not an issue but we need to mark the freed
memory as null to avoid a double free

Fixes https://gitlab.com/kicad/code/kicad/issues/12981

(cherry picked from commit 62863d6c5b)
This commit is contained in:
Seth Hillbrand 2022-11-22 06:09:19 -08:00
parent 3b3e86b968
commit 554d82b2a4
1 changed files with 2 additions and 0 deletions

View File

@ -249,6 +249,7 @@ COMPILER::~COMPILER()
if( m_tree ) if( m_tree )
{ {
freeTree( m_tree ); freeTree( m_tree );
m_tree = nullptr;
} }
// Allow explicit call to destructor // Allow explicit call to destructor
@ -693,6 +694,7 @@ void COMPILER::freeTree( LIBEVAL::TREE_NODE *tree )
freeTree( tree->leaf[1] ); freeTree( tree->leaf[1] );
delete tree->uop; delete tree->uop;
tree->uop = nullptr;
} }