From be74806044c117900a5c075bbd3029cf7d0260ac Mon Sep 17 00:00:00 2001 From: Johan Bjork Date: Thu, 4 Feb 2016 18:34:08 -0500 Subject: [PATCH] Fix read-after-free error detected by valgrind, bug1031. Signed-off-by: Wilson Snyder --- Changes | 2 ++ src/V3Scope.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index b77ce5895..2db9184d1 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix using short parameter names on negative params, bug1022. [Duraid Madina] +**** Fix read-after-free error, bug1031. [Johan Bjork] + * Verilator 3.880 2015-12-19 diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 644b5f88d..3498e568a 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -334,7 +334,9 @@ private: nodep->iterateChildren(*this); } else { // A block that was just moved under a scope, Kill it. - nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); + // Certain nodes can be referenced later in this pass, notably + // an FTaskRef needs to access the FTask to find the cloned task + pushDeletep(nodep->unlinkFrBack()); VL_DANGLING(nodep); } }