Correct handling of corner-cases involving custom iterators:

- Under some conditions, comparing `ReadViewFwdRange::iterators`
  for equality could derefence an empty `std::unique_ptr` which
  will result in a crash.
- Misuse of the `equal` API could result in a `std::bad_cast`
  exception being thrown from when iterating transactions or
  SLEs from the `OpenView`, `RawStateTable` and `Ledger` classes.
This commit is contained in:
Nik Bougalis
2020-12-07 14:34:30 -08:00
parent e96a719724
commit deea16e14f
7 changed files with 51 additions and 31 deletions

View File

@@ -45,8 +45,9 @@ public:
bool
equal(base_type const& impl) const override
{
auto const& other = dynamic_cast<txs_iter_impl const&>(impl);
return iter_ == other.iter_;
if (auto const p = dynamic_cast<txs_iter_impl const*>(&impl))
return iter_ == p->iter_;
return false;
}
void