Address CodeQL issues (#646)

* Address CodeQL issues

* Update contrib/win32/win32compat/console.c

Co-authored-by: Tess Gauthier <tgauth@bu.edu>

* Update contrib/win32/win32compat/console.c

Co-authored-by: Tess Gauthier <tgauth@bu.edu>

Co-authored-by: Tess Gauthier <tgauth@bu.edu>
This commit is contained in:
Paul Higinbotham 2022-12-05 13:29:32 -08:00 committed by GitHub
parent 043a20b808
commit c971eda4d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -627,16 +627,14 @@ ConWriteString(char* pszString, int cbString)
if ((needed = MultiByteToWideChar(CP_UTF8, 0, pszString, cbString, NULL, 0)) == 0 ||
(utf16 = malloc(needed * sizeof(wchar_t))) == NULL ||
(cnt = MultiByteToWideChar(CP_UTF8, 0, pszString, cbString, utf16, needed)) == 0) {
const char* pszStringConst = pszString;
Result = (DWORD)printf_s(pszStringConst);
Result = (DWORD)printf_s(pszString); // CodeQL [SM01734] false positive: call is not format string with arguments.
}
else {
if (GetConsoleOutputHandle())
WriteConsoleW(GetConsoleOutputHandle(), utf16, cnt, &Result, 0);
else
{
const wchar_t* utf16Const = utf16;
Result = (DWORD)wprintf_s(utf16Const);
Result = (DWORD)wprintf_s(utf16); // CodeQL [SM01734] false positive: call is not format string with arguments.
}
}