Skip to content

Commit dcbf671

Browse files
fanquakeknst
authored andcommitted
Merge bitcoin#30131: wallet, tests: Avoid stringop-overflow warning in PollutePubKey
2289d45 wallet, tests: Avoid stringop-overflow warning in PollutePubKey (Ava Chow) Pull request description: Fixes bitcoin#30114 ACKs for top commit: maflcko: ACK 2289d45 with g++ 14.1.1 🦄 theStack: utACK 2289d45 laanwj: ACK 2289d45 Tree-SHA512: 173c3c299bdd890f73e8a67a37880dbf816265e8b3c8298557ef2fc4670f5447005c0d2d81726f9bc43f6a69d677365d90a604354b3cbab0e3c52c4526d0407e
1 parent 3f0c2ff commit dcbf671

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
@@ -531,8 +531,10 @@ static void TestWatchOnlyPubKey(LegacyScriptPubKeyMan* spk_man, const CPubKey& a
531531
// Cryptographically invalidate a PubKey whilst keeping length and first byte
532532
static void PollutePubKey(CPubKey& pubkey)
533533
{
534-
std::vector<unsigned char> pubkey_raw(pubkey.begin(), pubkey.end());
535-
std::fill(pubkey_raw.begin()+1, pubkey_raw.end(), 0);
534+
assert(pubkey.size() >= 1);
535+
std::vector<unsigned char> pubkey_raw;
536+
pubkey_raw.push_back(pubkey[0]);
537+
pubkey_raw.insert(pubkey_raw.end(), pubkey.size() - 1, 0);
536538
pubkey = CPubKey(pubkey_raw);
537539
assert(!pubkey.IsFullyValid());
538540
assert(pubkey.IsValid());

0 commit comments

Comments
 (0)