Add default deleter for copy assign operator in SSHPublicKey

This commit is contained in:
Gamezardashvili George 2023-06-21 19:43:04 +03:00
parent debf74a854
commit d2964c7fe2
2 changed files with 4 additions and 2 deletions

View File

@ -45,7 +45,8 @@ SSHPublicKey & SSHPublicKey::operator=(const SSHPublicKey & other)
{
throw DB::Exception(DB::ErrorCodes::SSH_EXCEPTION, "Failed to duplicate ssh_key");
}
key.reset(new_key);
key = UniqueKeyPtr(new_key, deleter); // We don't have access to the pointer from external code, opposed to non owning key object.
// So here we always go for default deleter, regardless of other's
}
return *this;
}

View File

@ -61,7 +61,8 @@ private:
// We may want to not own ssh_key memory, so then we pass this deleter to unique_ptr
static void disabledDeleter(KeyPtr) { }
std::unique_ptr<ssh_key_struct, decltype(&deleter)> key;
using UniqueKeyPtr = std::unique_ptr<ssh_key_struct, decltype(&deleter)>;
UniqueKeyPtr key;
};
}