From a40bd374aaf8e10116fa664fa7b480d85ee2fe59 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Mon, 31 Mar 2025 13:05:20 -0400 Subject: [PATCH] Get*Union: disallow nulltpr Refs --- src/txgraph.cpp | 2 ++ src/txgraph.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/txgraph.cpp b/src/txgraph.cpp index 22dce81fee1..9e4bf116b02 100644 --- a/src/txgraph.cpp +++ b/src/txgraph.cpp @@ -1595,6 +1595,7 @@ std::vector TxGraphImpl::GetAncestorsUnion(std::span> matches; matches.reserve(args.size()); for (auto arg : args) { + Assume(arg); // Skip empty Refs. if (GetRefGraph(*arg) == nullptr) continue; Assume(GetRefGraph(*arg) == this); @@ -1627,6 +1628,7 @@ std::vector TxGraphImpl::GetDescendantsUnion(std::span> matches; matches.reserve(args.size()); for (auto arg : args) { + Assume(arg); // Skip empty Refs. if (GetRefGraph(*arg) == nullptr) continue; Assume(GetRefGraph(*arg) == this); diff --git a/src/txgraph.h b/src/txgraph.h index 91c3bd5cb17..cdfb2fe6dec 100644 --- a/src/txgraph.h +++ b/src/txgraph.h @@ -144,11 +144,11 @@ public: virtual std::vector GetDescendants(const Ref& arg, bool main_only = false) noexcept = 0; /** Like GetAncestors, but return the Refs for all transactions in the union of the provided * arguments' ancestors (each transaction is only reported once). Refs that do not exist in - * the queried graph are ignored. */ + * the queried graph are ignored. Null refs are not allowed. */ virtual std::vector GetAncestorsUnion(std::span args, bool main_only = false) noexcept = 0; /** Like GetDescendants, but return the Refs for all transactions in the union of the provided * arguments' descendants (each transaction is only reported once). Refs that do not exist in - * the queried graph are ignored. */ + * the queried graph are ignored. Null refs are not allowed. */ virtual std::vector GetDescendantsUnion(std::span args, bool main_only = false) noexcept = 0; /** Get the total number of transactions in the graph. If main_only is false and a staging * graph exists, it is queried; otherwise the main graph is queried. This is available even