diff --git a/src/script/miniscript.h b/src/script/miniscript.h index 74600292b01..a1ca3eaa32a 100644 --- a/src/script/miniscript.h +++ b/src/script/miniscript.h @@ -532,9 +532,11 @@ struct Node { //! The Script context for this node. Either P2WSH or Tapscript. const MiniscriptContext m_script_ctx; - /* Destroy the shared pointers iteratively to avoid a stack-overflow due to recursive calls - * to the subs' destructors. */ - ~Node() { + ~Node() + { + // Destroy the subexpressions iteratively after moving out their + // subexpressions to avoid a stack-overflow due to recursive calls to + // the subs' destructors. while (!subs.empty()) { auto node = std::move(subs.back()); subs.pop_back();