mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add safe_cast (RIPD-1702):
This change ensures that no overflow can occur when casting between enums and integral types.
This commit is contained in:
committed by
Nik Bougalis
parent
494724578a
commit
148bbf4e8f
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <ripple/peerfinder/impl/Livecache.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/basics/safe_cast.h>
|
||||
#include <ripple/beast/unit_test.h>
|
||||
#include <ripple/beast/clock/manual_clock.h>
|
||||
#include <test/beast/IPEndpointCommon.h>
|
||||
@@ -134,7 +135,7 @@ public:
|
||||
add(
|
||||
beast::IP::randomEP(true),
|
||||
c,
|
||||
ripple::rand_int(0, static_cast<int>(Tuning::maxHops + 1)));
|
||||
ripple::rand_int(0, safe_cast<int>(Tuning::maxHops + 1)));
|
||||
auto h = c.hops.histogram();
|
||||
if(! BEAST_EXPECT(! h.empty()))
|
||||
return;
|
||||
@@ -159,7 +160,7 @@ public:
|
||||
add(
|
||||
beast::IP::randomEP(true),
|
||||
c,
|
||||
ripple::rand_int(0, static_cast<int>(Tuning::maxHops + 1)));
|
||||
ripple::rand_int(0, safe_cast<int>(Tuning::maxHops + 1)));
|
||||
|
||||
using at_hop = std::vector <ripple::PeerFinder::Endpoint>;
|
||||
using all_hops = std::array <at_hop, 1 + Tuning::maxHops + 1>;
|
||||
|
||||
Reference in New Issue
Block a user