From 62863d6c5b035a0e8a82f2d7a8be95782c939936 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand <seth@kipro-pcb.com> Date: Tue, 22 Nov 2022 06:09:19 -0800 Subject: [PATCH] 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 --- common/libeval_compiler/libeval_compiler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index 2b5e59928b..98ec77182a 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -250,6 +250,7 @@ COMPILER::~COMPILER() if( m_tree ) { freeTree( m_tree ); + m_tree = nullptr; } // Allow explicit call to destructor @@ -694,6 +695,7 @@ void COMPILER::freeTree( LIBEVAL::TREE_NODE *tree ) freeTree( tree->leaf[1] ); delete tree->uop; + tree->uop = nullptr; }