mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 22:59:29 +02:00
+ Win32 SEH: to avoid memory leaks, it is necessary to free exception object for non-FPC exceptions on re-raise (it will be re-created by next exception handler).
git-svn-id: trunk@26241 -
This commit is contained in:
parent
ee152cde6a
commit
b82b6da493
@ -335,6 +335,7 @@
|
||||
Frames : PCodePointer;
|
||||
{$ifdef FPC_USE_WIN32_SEH}
|
||||
SEHFrame : Pointer;
|
||||
ExceptRec : Pointer;
|
||||
ReraiseBuf : jmp_buf;
|
||||
{$endif FPC_USE_WIN32_SEH}
|
||||
end;
|
||||
|
@ -75,6 +75,15 @@ var
|
||||
begin
|
||||
hp:=ExceptObjectStack;
|
||||
ExceptObjectStack:=hp^.next;
|
||||
{ Since we're going to 'reraise' the original OS exception (or, more exactly, pretend
|
||||
it wasn't handled), we must revert action of CommonHandler. }
|
||||
if TExceptionRecord(hp^.ExceptRec^).ExceptionCode<>FPC_EXCEPTION_CODE then
|
||||
begin
|
||||
if assigned(hp^.frames) then
|
||||
freemem(hp^.frames);
|
||||
if hp^.refcount=0 then
|
||||
hp^.FObject.Free;
|
||||
end;
|
||||
TSEHFrame(hp^.SEHFrame^).Addr:=@NullHandler;
|
||||
longjmp(hp^.ReraiseBuf,1);
|
||||
end;
|
||||
@ -224,6 +233,7 @@ begin
|
||||
|
||||
Exc.Refcount:=0;
|
||||
Exc.SEHFrame:=@frame;
|
||||
Exc.ExceptRec:=@rec;
|
||||
{ link to ExceptObjectStack }
|
||||
Exc.Next:=ExceptObjectStack;
|
||||
ExceptObjectStack:=@Exc;
|
||||
|
Loading…
Reference in New Issue
Block a user