Skip to content

Commit e2939e3

Browse files
committed
ReviveOverlay: Fix assert when using empty credentials.
1 parent 7fbf999 commit e2939e3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ReviveOverlay/windowsservices.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool WindowsServices::PromptCredentials(QString& user, QString& password, bool f
9696
pcred.hbmBanner = nullptr;
9797
DWORD result = CredUIPromptForWindowsCredentialsW(&pcred, failed ? ERROR_LOGON_FAILURE : 0, &pkg, packedAuth.constData(), packedAuth.size(), &authBuffer, &authSize, &save, flags);
9898
packedAuth.fill(0);
99-
if (result == NO_ERROR)
99+
if (result == ERROR_SUCCESS)
100100
{
101101
DWORD userSize = 0, passwordSize = 0;
102102
CredUnPackAuthenticationBufferW(0,
@@ -114,8 +114,8 @@ bool WindowsServices::PromptCredentials(QString& user, QString& password, bool f
114114
user.resize(userSize - 1);
115115
password.reserve(passwordSize);
116116
password.resize(passwordSize - 1);
117-
Q_ASSERT(user.capacity() == userSize);
118-
Q_ASSERT(password.capacity() == passwordSize);
117+
Q_ASSERT(user.capacity() >= userSize);
118+
Q_ASSERT(password.capacity() >= passwordSize);
119119

120120
CredUnPackAuthenticationBufferW(0,
121121
authBuffer, authSize,
@@ -149,6 +149,13 @@ bool WindowsServices::ReadCredentials(QString& user, QString& password)
149149

150150
bool WindowsServices::WriteCredentials(const QString& user, const QString& password)
151151
{
152+
if (user.isEmpty() && password.isEmpty())
153+
{
154+
// Did you mean to do this?
155+
DeleteCredentials();
156+
return true;
157+
}
158+
152159
// We're casting a bunch of const away here, but it should be safe
153160
CREDENTIALW cred = {0};
154161
cred.Type = CRED_TYPE_GENERIC;

0 commit comments

Comments
 (0)