aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-05-17 14:31:56 -0400
committerAva Chow <github@achow101.com>2024-05-21 12:59:47 -0400
commit2289d4524053ab71c0d9133987cb36412797c1a2 (patch)
tree06dbe1f59f37ace4102e6d6b0494ec099d63e1d6 /src/wallet
parent2f53f2273da020d7fabd7c65a1bc7e69a31249b2 (diff)
downloadbitcoin-2289d4524053ab71c0d9133987cb36412797c1a2.tar.xz
wallet, tests: Avoid stringop-overflow warning in PollutePubKey
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/test/wallet_tests.cpp6
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());