Skip to content

Commit 56e07db

Browse files
author
Lukasz Kostyra
committed
8335216: [windows] Missing error check for GetSystemDirectory in glass
Reviewed-by: mstrauss, kcr
1 parent 72701e6 commit 56e07db

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

modules/javafx.graphics/src/main/native-glass/win/RoActivationSupport.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,19 @@ void tryInitializeRoActivationSupport()
6969
wchar_t path[MAX_PATH];
7070
wchar_t file[MAX_PATH];
7171

72-
if (GetSystemDirectory(path, sizeof(path) / sizeof(wchar_t)) == 0) {
72+
UINT pathSize = sizeof(path) / sizeof(wchar_t);
73+
UINT rval = GetSystemDirectoryW(path, pathSize);
74+
if (rval == 0 || rval >= pathSize) {
75+
fprintf(stderr, "WinRT: Failed to fetch system directory");
7376
return;
7477
}
7578

7679
memcpy_s(file, sizeof(file), path, sizeof(path));
77-
wcscat_s(file, MAX_PATH-1, L"\\combase.dll");
80+
if (wcscat_s(file, MAX_PATH-1, L"\\combase.dll") != 0) {
81+
fprintf(stderr, "WinRT: Failed to form path to combase.dll");
82+
return;
83+
}
84+
7885
hLibComBase = LoadLibraryW(file);
7986
if (!hLibComBase) {
8087
fprintf(stderr, moduleNotFoundMessage, "combase.dll");

0 commit comments

Comments
 (0)