diff options
| author | pierrenn <[email protected]> | 2020-04-08 15:10:28 +0900 |
|---|---|---|
| committer | pierrenn <[email protected]> | 2020-04-09 08:32:00 +0900 |
| commit | 2748e8793267126c5b40621d75d1930e358f057e (patch) | |
| tree | 2c60aea1c57f44cab3b835ed33b3ccae2e40b950 /src/script | |
| parent | Merge #18532: rpc: Avoid initialization-order-fiasco on static CRPCCommand ta... (diff) | |
| download | discoin-2748e8793267126c5b40621d75d1930e358f057e.tar.xz discoin-2748e8793267126c5b40621d75d1930e358f057e.zip | |
script: prevent UB when computing abs value for num opcode serialize
Diffstat (limited to 'src/script')
| -rw-r--r-- | src/script/script.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/script/script.h b/src/script/script.h index 7aaa10b60..866517ba2 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -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) { |