Skip to content

Commit e009bf6

Browse files
committed
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.
1 parent 41544b8 commit e009bf6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/node/mini_miner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct IteratorComparator
6363
template<typename I>
6464
bool operator()(const I& a, const I& b) const
6565
{
66-
return &(*a) < &(*b);
66+
return a->first < b->first;
6767
}
6868
};
6969

src/txorphanage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TxOrphanage {
9292
template<typename I>
9393
bool operator()(const I& a, const I& b) const
9494
{
95-
return &(*a) < &(*b);
95+
return a->first < b->first;
9696
}
9797
};
9898

0 commit comments

Comments
 (0)