diff --git a/src/winmain/qtmain_win.cpp b/src/winmain/qtmain_win.cpp index 752fba1d5a..0f29c6ac95 100644 --- a/src/winmain/qtmain_win.cpp +++ b/src/winmain/qtmain_win.cpp @@ -82,7 +82,7 @@ extern "C" int main(int, char **); // Convert a wchar_t to char string, equivalent to QString::toLocal8Bit() // when passed CP_ACP. -static inline char *wideToMulti(int codePage, const wchar_t *aw) +static inline char *wideToMulti(unsigned int codePage, const wchar_t *aw) { const int required = WideCharToMultiByte(codePage, 0, aw, -1, nullptr, 0, nullptr, nullptr); char *result = new char[required]; @@ -92,17 +92,17 @@ static inline char *wideToMulti(int codePage, const wchar_t *aw) extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int /* cmdShow */) { - int argc; + int argc = 0; wchar_t **argvW = CommandLineToArgvW(GetCommandLineW(), &argc); - if (!argvW) + if (argvW == nullptr) return -1; char **argv = new char *[argc + 1]; - for (int i = 0; i < argc; ++i) + for (int i = 0; i != argc; ++i) argv[i] = wideToMulti(CP_ACP, argvW[i]); argv[argc] = nullptr; LocalFree(argvW); const int exitCode = main(argc, argv); - for (int i = 0; i < argc && argv[i]; ++i) + for (int i = 0; (i != argc) && (argv[i] != nullptr); ++i) delete [] argv[i]; delete [] argv; return exitCode;