From 5aa7430f5687ea95080e46f1d16c8a023172ac51 Mon Sep 17 00:00:00 2001 From: Le Liu Date: Sun, 27 Nov 2016 19:09:42 +0800 Subject: 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_ --- singleapplication.cpp | 4 +--- 1 file changed, 1 insertion(+), 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() ); } -- cgit v1.2.1