WASAPI: fix empty audio device in settings dialog after c401513a2994c09ca07f860e3a044...
authorRainer Hochecker <fernetmenta@online.de>
Sun, 27 Jul 2014 08:00:35 +0000 (10:00 +0200)
committerRainer Hochecker <fernetmenta@online.de>
Sun, 27 Jul 2014 08:05:18 +0000 (10:05 +0200)
xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp

index 3dd1029..db73c29 100644 (file)
@@ -169,11 +169,14 @@ std::string localWideToUtf(LPCWSTR wstr)
   if (wstr == NULL)
     return "";
   int bufSize = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
-  std::string strA ("", bufSize);
-  strA.resize(bufSize);
-  if ( bufSize == 0 || WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &strA[0], bufSize, NULL, NULL) != bufSize )
-    strA.clear();
-  return strA;
+  char *multiStr = new char[bufSize + 1];
+  if (bufSize == 0 || WideCharToMultiByte(CP_UTF8, 0, wstr, -1, multiStr, bufSize, NULL, NULL) != bufSize)
+    multiStr[0] = 0;
+  else
+    multiStr[bufSize] = 0;
+  std::string ret(multiStr);
+  delete[] multiStr;
+  return ret;
 }
 
 CAESinkWASAPI::CAESinkWASAPI() :