nextcloud-desktop/src/gui/wizard/abstractcredswizardpage.cpp
Matthieu Gallien ecc588c27a avoid possibly crashing static_cast
ran
run-clang-tidy-14.py -header-filter='.*' -checks='-*,cppcoreguidelines-pro-type-static-cast-downcast' -fix

this can prevent casting to a type that is unrelated to the real type
and later cause a crash because you go into undefined behavior domain

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
2022-10-03 10:23:24 +02:00

38 lines
1.2 KiB
C++

/*
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "creds/abstractcredentials.h"
#include "creds/credentialsfactory.h"
#include "account.h"
#include "wizard/owncloudwizard.h"
#include "wizard/abstractcredswizardpage.h"
#include <accountmanager.h>
namespace OCC {
void AbstractCredentialsWizardPage::cleanupPage()
{
// Reset the credentials when the 'Back' button is used.
AccountPtr account = dynamic_cast<OwncloudWizard *>(wizard())->account();
AbstractCredentials *creds = account->credentials();
if (creds) {
if (!creds->inherits("DummyCredentials")) {
account->setCredentials(CredentialsFactory::create("dummy"));
}
}
}
}