mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 22:28:06 +02:00
* fix for Mantis #35862: free the list of functions added with AddTerminateProc to avoid memory leaks
+ added test git-svn-id: trunk@42457 -
This commit is contained in:
parent
48d0ab1af9
commit
176a63b67b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -16698,6 +16698,7 @@ tests/webtbs/tw3577.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3578.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3579.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3583.pp svneol=native#text/plain
|
||||
tests/webtbs/tw35862.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw3589.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3594.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3595.pp svneol=native#text/plain
|
||||
|
@ -955,4 +955,5 @@ Initialization
|
||||
RefreshDeviceList;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -533,4 +533,5 @@ Initialization
|
||||
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -292,4 +292,5 @@ Initialization
|
||||
InitExceptions;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -1341,4 +1341,5 @@ Initialization
|
||||
InitInternational; { Initialize internationalization settings }
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -326,4 +326,5 @@ Initialization
|
||||
InitExceptions;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -921,4 +921,5 @@ Initialization
|
||||
OnBeep:=@SysBeep;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -850,4 +850,5 @@ Initialization
|
||||
InitInternational; { Initialize internationalization settings }
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -930,4 +930,5 @@ Initialization
|
||||
OnBeep:=@SysBeep;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -1264,4 +1264,5 @@ initialization
|
||||
OnBeep := @SysBeep;
|
||||
finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -365,4 +365,5 @@ Initialization
|
||||
InitExceptions;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -662,4 +662,5 @@ Initialization
|
||||
OnBeep:=@SysBeep;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -729,4 +729,5 @@ Initialization
|
||||
InitInternational; { Initialize internationalization settings }
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -653,6 +653,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure FreeTerminateProcs;
|
||||
var
|
||||
TPR1, TPR2: PPRecord;
|
||||
begin
|
||||
TPR1 := TPList;
|
||||
TPList := Nil;
|
||||
while Assigned(TPR1) do begin
|
||||
TPR2 := TPR1^.NextFunc;
|
||||
Dispose(TPR1);
|
||||
TPR1 := TPR2;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Diskh functions, OS independent.
|
||||
---------------------------------------------------------------------}
|
||||
|
@ -1004,4 +1004,5 @@ Initialization
|
||||
OrigOSErrorWatch := TOSErrorWatch (SetOSErrorTracking (@TrackLastOSError));
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -292,4 +292,5 @@ Initialization
|
||||
InitExceptions;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -1664,4 +1664,5 @@ Initialization
|
||||
Finalization
|
||||
FreeDriveStr;
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -899,4 +899,5 @@ Initialization
|
||||
InitDelay;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -295,4 +295,5 @@ Initialization
|
||||
InitExceptions;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -1659,4 +1659,5 @@ Initialization
|
||||
OnBeep:=@SysBeep;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -952,4 +952,5 @@ Initialization
|
||||
OnBeep:=@SysBeep;
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
end.
|
||||
|
@ -983,5 +983,6 @@ Initialization
|
||||
|
||||
Finalization
|
||||
DoneExceptions;
|
||||
FreeTerminateProcs;
|
||||
|
||||
end.
|
||||
|
22
tests/webtbs/tw35862.pp
Normal file
22
tests/webtbs/tw35862.pp
Normal file
@ -0,0 +1,22 @@
|
||||
{ %OPT=-gh }
|
||||
|
||||
program tw35862;
|
||||
|
||||
{$modeswitch result}
|
||||
|
||||
uses sysutils;
|
||||
|
||||
function do_term:boolean;
|
||||
begin
|
||||
writeln('In terminate proc');
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
begin
|
||||
HaltOnNotReleased:=True;
|
||||
|
||||
writeln('Adding terminate proc');
|
||||
AddTerminateproc(@do_term);
|
||||
writeln('terminating');
|
||||
CallterminateProcs;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user