addrman: Replace assert with throw on corrupt data

Assert should only be used for program internal logic errors, not to
sanitize external user input.
This commit is contained in:
MarcoFalke
2021-08-18 09:57:56 +02:00
parent fa298971e6
commit fa7a883f5a
2 changed files with 16 additions and 2 deletions

View File

@@ -386,7 +386,12 @@ void CAddrMan::Unserialize(Stream& s_)
LogPrint(BCLog::ADDRMAN, "addrman lost %i new and %i tried addresses due to collisions or invalid addresses\n", nLostUnk, nLost);
}
Check();
const int check_code{ForceCheckAddrman()};
if (check_code != 0) {
throw std::ios_base::failure(strprintf(
"Corrupt data. Consistency check failed with code %s",
check_code));
}
}
// explicit instantiation