From a76ae3112653f02119b5758d3cb65cf03c873dd3 Mon Sep 17 00:00:00 2001 From: Andrew Nelless Date: Mon, 19 Dec 2016 18:08:41 +0000 Subject: [PATCH] Fix OpenService buffer for building with narrow char type --- src/gui/src/MainWindow.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index f97c0630..7466a144 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -1258,15 +1258,8 @@ bool MainWindow::isServiceRunning(QString name) return false; } - SC_HANDLE hService; - int length = name.length(); - wchar_t* array = new wchar_t[length + 1]; - name.toWCharArray(array); - array[length] = '\0'; - - hService = OpenService(hSCManager, array, SERVICE_QUERY_STATUS); - - delete[] array; + auto array = name.toLocal8Bit(); + SC_HANDLE hService = OpenService(hSCManager, array.data(), SERVICE_QUERY_STATUS); if (hService == NULL) { appendLogDebug("failed to open service: " + name);