diff options
author | Ava Chow <github@achow101.com> | 2024-05-17 14:31:56 -0400 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-05-21 12:59:47 -0400 |
commit | 2289d4524053ab71c0d9133987cb36412797c1a2 (patch) | |
tree | 06dbe1f59f37ace4102e6d6b0494ec099d63e1d6 | |
parent | 2f53f2273da020d7fabd7c65a1bc7e69a31249b2 (diff) |
wallet, tests: Avoid stringop-overflow warning in PollutePubKey
-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()); |