aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordergoegge <n.goeggi@gmail.com>2024-06-19 09:57:22 +0100
committerdergoegge <n.goeggi@gmail.com>2024-06-19 10:14:31 +0100
commite009bf681c0e38a6451afa594ba3c7c8861f61c3 (patch)
tree8d387f3dbf4006cbbb1c2f15affd4a9190ec3382
parent41544b8f96dbc9c6b8998acd6522200d67cdc16d (diff)
Don't use iterator addresses in IteratorComparator
The addresses of the iterator values are non-deterministic (i.e. they depend on where the values were allocated). This causes stability issues when fuzzing (e.g. in the `txorphan` and `mini_miner` harnesses), due the orders (derived from IteratorComparator) not being deterministic. Improve stability by comparing the first element in the iterator value pair instead of using the the value addresses.
-rw-r--r--src/node/mini_miner.h2
-rw-r--r--src/txorphanage.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/node/mini_miner.h b/src/node/mini_miner.h
index de62c0af75..aec2aaf6b6 100644
--- a/src/node/mini_miner.h
+++ b/src/node/mini_miner.h
@@ -63,7 +63,7 @@ struct IteratorComparator
template<typename I>
bool operator()(const I& a, const I& b) const
{
- return &(*a) < &(*b);
+ return a->first < b->first;
}
};
diff --git a/src/txorphanage.h b/src/txorphanage.h
index 3054396b2d..3083c8467f 100644
--- a/src/txorphanage.h
+++ b/src/txorphanage.h
@@ -92,7 +92,7 @@ protected:
template<typename I>
bool operator()(const I& a, const I& b) const
{
- return &(*a) < &(*b);
+ return a->first < b->first;
}
};