diff options
author | merge-script <fanquake@gmail.com> | 2024-05-22 13:43:33 +0100 |
---|---|---|
committer | merge-script <fanquake@gmail.com> | 2024-05-22 13:43:33 +0100 |
commit | 93bec6e953172c14fc65aa1e9e363a5a9188ba37 (patch) | |
tree | 9e7823e4259ddba6b4c6d7bb930115fc59cdf446 /src/wallet/test | |
parent | fa8cb0516d4198c56d3dc1252a5a899959e279aa (diff) | |
parent | 2289d4524053ab71c0d9133987cb36412797c1a2 (diff) | |
download | bitcoin-93bec6e953172c14fc65aa1e9e363a5a9188ba37.tar.xz |
Merge bitcoin/bitcoin#30131: wallet, tests: Avoid stringop-overflow warning in PollutePubKey
2289d4524053ab71c0d9133987cb36412797c1a2 wallet, tests: Avoid stringop-overflow warning in PollutePubKey (Ava Chow)
Pull request description:
Fixes #30114
ACKs for top commit:
maflcko:
ACK 2289d4524053ab71c0d9133987cb36412797c1a2 with g++ 14.1.1 🦄
theStack:
utACK 2289d4524053ab71c0d9133987cb36412797c1a2
laanwj:
ACK 2289d4524053ab71c0d9133987cb36412797c1a2
Tree-SHA512: 173c3c299bdd890f73e8a67a37880dbf816265e8b3c8298557ef2fc4670f5447005c0d2d81726f9bc43f6a69d677365d90a604354b3cbab0e3c52c4526d0407e
Diffstat (limited to 'src/wallet/test')
-rw-r--r-- | src/wallet/test/wallet_tests.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 3a67b9a433..0e7a8c1ce8 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -499,8 +499,10 @@ static void TestWatchOnlyPubKey(LegacyScriptPubKeyMan* spk_man, const CPubKey& a // Cryptographically invalidate a PubKey whilst keeping length and first byte static void PollutePubKey(CPubKey& pubkey) { - std::vector<unsigned char> pubkey_raw(pubkey.begin(), pubkey.end()); - std::fill(pubkey_raw.begin()+1, pubkey_raw.end(), 0); + assert(pubkey.size() >= 1); + std::vector<unsigned char> pubkey_raw; + pubkey_raw.push_back(pubkey[0]); + pubkey_raw.insert(pubkey_raw.end(), pubkey.size() - 1, 0); pubkey = CPubKey(pubkey_raw); assert(!pubkey.IsFullyValid()); assert(pubkey.IsValid()); |