mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 10:39:39 +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;
|
Frames : PCodePointer;
|
||||||
{$ifdef FPC_USE_WIN32_SEH}
|
{$ifdef FPC_USE_WIN32_SEH}
|
||||||
SEHFrame : Pointer;
|
SEHFrame : Pointer;
|
||||||
|
ExceptRec : Pointer;
|
||||||
ReraiseBuf : jmp_buf;
|
ReraiseBuf : jmp_buf;
|
||||||
{$endif FPC_USE_WIN32_SEH}
|
{$endif FPC_USE_WIN32_SEH}
|
||||||
end;
|
end;
|
||||||
|
@ -75,6 +75,15 @@ var
|
|||||||
begin
|
begin
|
||||||
hp:=ExceptObjectStack;
|
hp:=ExceptObjectStack;
|
||||||
ExceptObjectStack:=hp^.next;
|
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;
|
TSEHFrame(hp^.SEHFrame^).Addr:=@NullHandler;
|
||||||
longjmp(hp^.ReraiseBuf,1);
|
longjmp(hp^.ReraiseBuf,1);
|
||||||
end;
|
end;
|
||||||
@ -224,6 +233,7 @@ begin
|
|||||||
|
|
||||||
Exc.Refcount:=0;
|
Exc.Refcount:=0;
|
||||||
Exc.SEHFrame:=@frame;
|
Exc.SEHFrame:=@frame;
|
||||||
|
Exc.ExceptRec:=@rec;
|
||||||
{ link to ExceptObjectStack }
|
{ link to ExceptObjectStack }
|
||||||
Exc.Next:=ExceptObjectStack;
|
Exc.Next:=ExceptObjectStack;
|
||||||
ExceptObjectStack:=@Exc;
|
ExceptObjectStack:=@Exc;
|
||||||
|
Loading…
Reference in New Issue
Block a user