Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit f897710

Browse files
Fix memory leaked caused by Marshal.GetFunctionPointerForDelegate (#28074)
1 parent d7c967a commit f897710

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/vm/dllimportcallback.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,18 @@ void UMEntryThunk::Terminate()
961961
CONTRACTL
962962
{
963963
NOTHROW;
964+
MODE_ANY;
964965
}
965966
CONTRACTL_END;
966967

967968
m_code.Poison();
968969

970+
if (GetObjectHandle())
971+
{
972+
DestroyLongWeakHandle(GetObjectHandle());
973+
m_pObjectHandle = 0;
974+
}
975+
969976
s_thunkFreeList.AddToList(this);
970977
}
971978

src/vm/dllimportcallback.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -310,22 +310,6 @@ class UMEntryThunk
310310
#endif
311311
}
312312

313-
~UMEntryThunk()
314-
{
315-
CONTRACTL
316-
{
317-
NOTHROW;
318-
GC_NOTRIGGER;
319-
MODE_ANY;
320-
}
321-
CONTRACTL_END;
322-
323-
if (GetObjectHandle())
324-
{
325-
DestroyLongWeakHandle(GetObjectHandle());
326-
}
327-
}
328-
329313
void Terminate();
330314

331315
VOID RunTimeInit()

0 commit comments

Comments
 (0)