Skip to content

Commit b4bebc3

Browse files
committed
Merge #440: wallet, tests: Avoid stringop-overflow warning in PollutePubKey
62468fe wallet, tests: Avoid stringop-overflow warning in PollutePubKey (Ava Chow) Pull request description: This PR backports bitcoin/bitcoin#30131 to enhance the build experience with GCC 14. ACKs for top commit: jarolrod: ACK 62468fe Tree-SHA512: ff934217791cc99d2d08976bd7f2f4f980910f69cbd955fdd3e82ea6fb3d03e94fdb2a526584012c9a11124ba91dd5820ec7a942a599205e00f38f674a9c3586
2 parents be23a6e + 62468fe commit b4bebc3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/wallet/test/wallet_tests.cpp

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

0 commit comments

Comments
 (0)