aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLe Liu <liulex@users.noreply.github.com>2016-11-27 19:09:42 +0800
committerItay Grudev <itay-grudev@users.noreply.github.com>2016-11-27 11:09:42 +0000
commit5aa7430f5687ea95080e46f1d16c8a023172ac51 (patch)
tree63ae512bb4a66275648ab90d5b4f9171a1c0f5dd
parentSingle Application v.3.0.1a (diff)
downloadsingleapplication-5aa7430f5687ea95080e46f1d16c8a023172ac51.tar.xz
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_
-rw-r--r--singleapplication.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/singleapplication.cpp b/singleapplication.cpp
index 58eee7c..7070973 100644
--- a/singleapplication.cpp
+++ b/singleapplication.cpp
@@ -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() );
}