mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
script: prevent UB when computing abs value for num opcode serialize
This commit is contained in:
@@ -329,7 +329,7 @@ public:
|
||||
|
||||
std::vector<unsigned char> result;
|
||||
const bool neg = value < 0;
|
||||
uint64_t absvalue = neg ? -value : value;
|
||||
uint64_t absvalue = neg ? ~static_cast<uint64_t>(value) + 1 : static_cast<uint64_t>(value);
|
||||
|
||||
while(absvalue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user