script: prevent UB when computing abs value for num opcode serialize

This commit is contained in:
pierrenn
2020-04-08 15:10:28 +09:00
parent 1b151e3ffc
commit 2748e87932
3 changed files with 3 additions and 11 deletions

View File

@@ -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)
{