Skip to content

Commit 39ab719

Browse files
authored
Merge pull request #44 from bernd5/patch-1
Memory Leak after exception
2 parents 8b401d9 + 38ee45c commit 39ab719

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Source/DDetours.pas

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2239,7 +2239,12 @@ function TIntercept.InstallHook(TargetProc, InterceptProc: PByte; const Options:
22392239
begin
22402240
P := GetRoot(TargetProc);
22412241
PDscr := CreateNewDescriptor;
2242-
InsertDescriptor(P, PDscr);
2242+
try
2243+
InsertDescriptor(P, PDscr);
2244+
except
2245+
FreeMem(PDscr);
2246+
raise;
2247+
end;
22432248
end;
22442249
Result := AddHook(PDscr, InterceptProc);
22452250
end;

0 commit comments

Comments
 (0)