From b9aca02e21266c709bcc4dc51c04d787fcd5eed5 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Tue, 21 May 2019 16:24:19 -0700 Subject: [PATCH] Add null check in VoidFreeNativeLibrary (dotnet/coreclr#24685) Commit migrated from https://github.com/dotnet/coreclr/commit/308b6b63f49d9ddaca2d11e141fb5c39591ec766 --- src/coreclr/src/vm/util.hpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/coreclr/src/vm/util.hpp b/src/coreclr/src/vm/util.hpp index ddf9d82..5113df6 100644 --- a/src/coreclr/src/vm/util.hpp +++ b/src/coreclr/src/vm/util.hpp @@ -796,24 +796,14 @@ InternalSetupForComCall(-1, -1, -1, false) #include "unsafe.h" -inline void UnsafeTlsFreeForHolder(DWORD* addr) -{ - WRAPPER_NO_CONTRACT; - - if (addr && *addr != TLS_OUT_OF_INDEXES) { - UnsafeTlsFree(*addr); - *addr = TLS_OUT_OF_INDEXES; - } -} - -// A holder to make sure tls slot is released and memory for allocated one is set to TLS_OUT_OF_INDEXES -typedef Holder, UnsafeTlsFreeForHolder> TlsHolder; - -// A holder for HMODULE. +// A holder for NATIVE_LIBRARY_HANDLE. FORCEINLINE void VoidFreeNativeLibrary(NATIVE_LIBRARY_HANDLE h) { WRAPPER_NO_CONTRACT; + if (h == NULL) + return; + #ifdef FEATURE_PAL PAL_FreeLibraryDirect(h); #else -- 2.7.4