mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +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
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/basics/safe_cast.h>
|
||||
#include <ripple/overlay/Message.h>
|
||||
#include <ripple/overlay/impl/TrafficCount.h>
|
||||
#include <cstdint>
|
||||
@@ -38,7 +39,7 @@ Message::Message (::google::protobuf::Message const& message, int type)
|
||||
message.SerializeToArray (&mBuffer [Message::kHeaderBytes], messageBytes);
|
||||
}
|
||||
|
||||
mCategory = static_cast<int>(TrafficCount::categorize
|
||||
mCategory = safe_cast<int>(TrafficCount::categorize
|
||||
(message, type, false));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user