[PATCH] D33652: Close DynamicLibraries in reverse order they were opened.

Frederich Munch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 30 10:58:20 PDT 2017


marsupial updated this revision to Diff 100737.

https://reviews.llvm.org/D33652

Files:
  lib/Support/Unix/DynamicLibrary.inc
  lib/Support/Windows/DynamicLibrary.inc


Index: lib/Support/Windows/DynamicLibrary.inc
===================================================================
--- lib/Support/Windows/DynamicLibrary.inc
+++ lib/Support/Windows/DynamicLibrary.inc
@@ -23,7 +23,7 @@
 
 
 DynamicLibrary::HandleSet::~HandleSet() {
-  for (void *Handle : Handles)
+  for (void *Handle : llvm::reverse(Handles))
     FreeLibrary(HMODULE(Handle));
 
   // 'Process' should not be released on Windows.
Index: lib/Support/Unix/DynamicLibrary.inc
===================================================================
--- lib/Support/Unix/DynamicLibrary.inc
+++ lib/Support/Unix/DynamicLibrary.inc
@@ -15,7 +15,8 @@
 #include <dlfcn.h>
 
 DynamicLibrary::HandleSet::~HandleSet() {
-  for (void *Handle : Handles)
+  // Close the libraries in reverse order.
+  for (void *Handle : llvm::reverse(Handles))
     ::dlclose(Handle);
   if (Process)
     ::dlclose(Process);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33652.100737.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170530/3d051ba3/attachment.bin>


More information about the llvm-commits mailing list