Skip to content

Commit 4fefbbb

Browse files
committed
Free unused trampoline regions on abort
Similar to the implementation in SlimDetoursTransactionCommit.
1 parent f117cbb commit 4fefbbb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Source/SlimDetours/Transaction.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ SlimDetoursTransactionAbort(VOID)
9898
PVOID pMem;
9999
SIZE_T sMem;
100100
DWORD dwOld;
101+
BOOL freed = FALSE;
101102

102103
if (s_nPendingThreadId != NtCurrentThreadId())
103104
{
@@ -115,13 +116,18 @@ SlimDetoursTransactionAbort(VOID)
115116
{
116117
detour_free_trampoline(o->pTrampoline);
117118
o->pTrampoline = NULL;
119+
freed = TRUE;
118120
}
119121

120122
PDETOUR_OPERATION n = o->pNext;
121123
detour_memory_free(o);
122124
o = n;
123125
}
124126
s_pPendingOperations = NULL;
127+
if (freed)
128+
{
129+
detour_free_unused_trampoline_regions();
130+
}
125131

126132
// Make sure the trampoline pages are no longer writable.
127133
detour_runnable_trampoline_regions();

0 commit comments

Comments
 (0)