mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2024-11-15 12:15:43 +08:00
Fix crash when username contains Unicode characters on Windows (#17)
* Fixed bug on Windows with username containing wide characters causing the library to crash. _Le Liu_
This commit is contained in:
parent
e75f16a39a
commit
5aa7430f56
@ -82,9 +82,7 @@ void SingleApplicationPrivate::genBlockServerName( int timeout )
|
||||
// Specifies size of the buffer on input
|
||||
DWORD usernameLength = UNLEN + 1;
|
||||
if( GetUserName( username, &usernameLength ) ) {
|
||||
char buffer[512];
|
||||
size_t length = wcstombs( buffer, username, 512 );
|
||||
appData.addData( buffer, length );
|
||||
appData.addData( QString::fromWCharArray(username).toUtf8() );
|
||||
} else {
|
||||
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user