From 59cb235cbd1a4ec4d2a9cfaad4ea3767571cb29f Mon Sep 17 00:00:00 2001 From: Lukasz Kostyra Date: Mon, 8 Jul 2024 16:18:52 +0200 Subject: [PATCH] Improve Windows API use in RoActivationSupport --- .../src/main/native-glass/win/RoActivationSupport.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/javafx.graphics/src/main/native-glass/win/RoActivationSupport.cpp b/modules/javafx.graphics/src/main/native-glass/win/RoActivationSupport.cpp index e200cac0135..fd5cebe3af0 100644 --- a/modules/javafx.graphics/src/main/native-glass/win/RoActivationSupport.cpp +++ b/modules/javafx.graphics/src/main/native-glass/win/RoActivationSupport.cpp @@ -69,12 +69,19 @@ void tryInitializeRoActivationSupport() wchar_t path[MAX_PATH]; wchar_t file[MAX_PATH]; - if (GetSystemDirectory(path, sizeof(path) / sizeof(wchar_t)) == 0) { + UINT pathSize = sizeof(path) / sizeof(wchar_t); + UINT rval = GetSystemDirectoryW(path, pathSize); + if (rval == 0 || rval >= pathSize) { + fprintf(stderr, "WinRT: Failed to fetch system directory"); return; } memcpy_s(file, sizeof(file), path, sizeof(path)); - wcscat_s(file, MAX_PATH-1, L"\\combase.dll"); + if (wcscat_s(file, MAX_PATH-1, L"\\combase.dll") != 0) { + fprintf(stderr, "WinRT: Failed to form path to combase.dll"); + return; + } + hLibComBase = LoadLibraryW(file); if (!hLibComBase) { fprintf(stderr, moduleNotFoundMessage, "combase.dll");