Skip to content

Commit

Permalink
Merge 68ef952 into merged_master (Bitcoin PR #18413)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Nov 26, 2020
2 parents 2d0adcc + 68ef952 commit 9ea76b5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/script/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class CScriptNum

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)
{
Expand Down
6 changes: 1 addition & 5 deletions src/test/fuzz/integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)

const CScriptNum script_num{i64};
(void)script_num.getint();
// Avoid negation failure:
// script/script.h:332:35: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself
if (script_num != CScriptNum{std::numeric_limits<int64_t>::min()}) {
(void)script_num.getvch();
}
(void)script_num.getvch();

const arith_uint256 au256 = UintToArith256(u256);
assert(ArithToUint256(au256) == u256);
Expand Down
6 changes: 1 addition & 5 deletions src/test/fuzz/scriptnum_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ void test_one_input(const std::vector<uint8_t>& buffer)
break;
}
(void)script_num.getint();
// Avoid negation failure:
// script/script.h:332:35: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself
if (script_num != CScriptNum{std::numeric_limits<int64_t>::min()}) {
(void)script_num.getvch();
}
(void)script_num.getvch();
}
}

0 comments on commit 9ea76b5

Please sign in to comment.