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.
This commit is contained in:
1 parent
9f650062fc
commit
86ef7b3c7b
1 file changed
+2
-2
@@ -4093,8 +4093,8 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(std::shared_ptr<CWallet>
|
|||||||
|
|
||||||
// Make list of wallets to cleanup
|
// Make list of wallets to cleanup
|
||||||
std::vector<std::shared_ptr<CWallet>> created_wallets;
|
std::vector<std::shared_ptr<CWallet>> created_wallets;
|
||||||
created_wallets.push_back(std::move(res.watchonly_wallet));
|
if (res.watchonly_wallet) created_wallets.push_back(std::move(res.watchonly_wallet));
|
||||||
created_wallets.push_back(std::move(res.solvables_wallet));
|
if (res.solvables_wallet) created_wallets.push_back(std::move(res.solvables_wallet));
|
||||||
|
|
||||||
// Get the directories to remove after unloading
|
// Get the directories to remove after unloading
|
||||||
for (std::shared_ptr<CWallet>& w : created_wallets) {
|
for (std::shared_ptr<CWallet>& w : created_wallets) {
|
||||||
|
|||||||
Reference in new issue
Block a user