summaryrefslogtreecommitdiff
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-01-27 23:32:05 +0100
committerGitHub <noreply@github.com>2018-01-27 23:32:05 +0100
commitf12e8568d43de853e0b98588e7f132a61a92fc45 (patch)
tree31a13ffa7f3ccbebf3572ef59a7df7a09af6348f /platform/windows/os_windows.cpp
parent4553c81ceb7b9ee17fde2cf13623a32bf7f98078 (diff)
parent18e66a28bcda227e212d43bebaf09bd8ad34d3f2 (diff)
Merge pull request #16081 from djgaspa/dll-directory
Fix remove_dll_directory crash when cookie is null
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 9e22e8aaac..43f2a5cf7d 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1655,7 +1655,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han
PRemoveDllDirectory remove_dll_directory = (PRemoveDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "RemoveDllDirectory");
bool has_dll_directory_api = ((add_dll_directory != NULL) && (remove_dll_directory != NULL));
- DLL_DIRECTORY_COOKIE cookie;
+ DLL_DIRECTORY_COOKIE cookie = NULL;
if (p_also_set_library_path && has_dll_directory_api) {
cookie = add_dll_directory(path.get_base_dir().c_str());
@@ -1663,7 +1663,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han
p_library_handle = (void *)LoadLibraryExW(path.c_str(), NULL, (p_also_set_library_path && has_dll_directory_api) ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0);
- if (p_also_set_library_path && has_dll_directory_api) {
+ if (cookie) {
remove_dll_directory(cookie);
}