Skip to content

Commit 86ef7b3

Browse files
committed
wallet: Avoid null pointer deref when cleaning up migratewallet
If migratewallet fails, we do a cleanup which removes the watchonly and solvables wallets if they were created. However, if they were not, their pointers are nullptr and we don't check for that, which causes a segfault during the cleanup. So check that they aren't nullptr before cleaning them up.
1 parent 9f65006 commit 86ef7b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4093,8 +4093,8 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(std::shared_ptr<CWallet>
40934093

40944094
// Make list of wallets to cleanup
40954095
std::vector<std::shared_ptr<CWallet>> created_wallets;
4096-
created_wallets.push_back(std::move(res.watchonly_wallet));
4097-
created_wallets.push_back(std::move(res.solvables_wallet));
4096+
if (res.watchonly_wallet) created_wallets.push_back(std::move(res.watchonly_wallet));
4097+
if (res.solvables_wallet) created_wallets.push_back(std::move(res.solvables_wallet));
40984098

40994099
// Get the directories to remove after unloading
41004100
for (std::shared_ptr<CWallet>& w : created_wallets) {

0 commit comments

Comments
 (0)