aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorpierrenn <git@pnn.sh>2020-04-08 15:10:28 +0900
committerpierrenn <git@pnn.sh>2020-04-09 08:32:00 +0900
commit2748e8793267126c5b40621d75d1930e358f057e (patch)
tree2c60aea1c57f44cab3b835ed33b3ccae2e40b950 /src/script
parent1b151e3ffce7c1a2ee46bf280cc1d96775d1f91e (diff)
script: prevent UB when computing abs value for num opcode serialize
Diffstat (limited to 'src/script')
-rw-r--r--src/script/script.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/script/script.h b/src/script/script.h
index 7aaa10b60b..866517ba2d 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)
{