Skip to content

Commit 2289d45

Browse files
committed
wallet, tests: Avoid stringop-overflow warning in PollutePubKey
1 parent 2f53f22 commit 2289d45

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/wallet/test/wallet_tests.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,10 @@ static void TestWatchOnlyPubKey(LegacyScriptPubKeyMan* spk_man, const CPubKey& a
499499
// Cryptographically invalidate a PubKey whilst keeping length and first byte
500500
static void PollutePubKey(CPubKey& pubkey)
501501
{
502-
std::vector<unsigned char> pubkey_raw(pubkey.begin(), pubkey.end());
503-
std::fill(pubkey_raw.begin()+1, pubkey_raw.end(), 0);
502+
assert(pubkey.size() >= 1);
503+
std::vector<unsigned char> pubkey_raw;
504+
pubkey_raw.push_back(pubkey[0]);
505+
pubkey_raw.insert(pubkey_raw.end(), pubkey.size() - 1, 0);
504506
pubkey = CPubKey(pubkey_raw);
505507
assert(!pubkey.IsFullyValid());
506508
assert(pubkey.IsValid());

0 commit comments

Comments
 (0)