* 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:
svenbarth 2019-07-19 15:55:21 +00:00
parent 48d0ab1af9
commit 176a63b67b
23 changed files with 56 additions and 0 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -955,4 +955,5 @@ Initialization
RefreshDeviceList;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -533,4 +533,5 @@ Initialization
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -292,4 +292,5 @@ Initialization
InitExceptions;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -1341,4 +1341,5 @@ Initialization
InitInternational; { Initialize internationalization settings }
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -326,4 +326,5 @@ Initialization
InitExceptions;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -921,4 +921,5 @@ Initialization
OnBeep:=@SysBeep;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -850,4 +850,5 @@ Initialization
InitInternational; { Initialize internationalization settings }
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -930,4 +930,5 @@ Initialization
OnBeep:=@SysBeep;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -1264,4 +1264,5 @@ initialization
OnBeep := @SysBeep;
finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -365,4 +365,5 @@ Initialization
InitExceptions;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -662,4 +662,5 @@ Initialization
OnBeep:=@SysBeep;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -729,4 +729,5 @@ Initialization
InitInternational; { Initialize internationalization settings }
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -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.
---------------------------------------------------------------------}

View File

@ -1004,4 +1004,5 @@ Initialization
OrigOSErrorWatch := TOSErrorWatch (SetOSErrorTracking (@TrackLastOSError));
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -292,4 +292,5 @@ Initialization
InitExceptions;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -1664,4 +1664,5 @@ Initialization
Finalization
FreeDriveStr;
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -899,4 +899,5 @@ Initialization
InitDelay;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -295,4 +295,5 @@ Initialization
InitExceptions;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -1659,4 +1659,5 @@ Initialization
OnBeep:=@SysBeep;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -952,4 +952,5 @@ Initialization
OnBeep:=@SysBeep;
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

View File

@ -983,5 +983,6 @@ Initialization
Finalization
DoneExceptions;
FreeTerminateProcs;
end.

22
tests/webtbs/tw35862.pp Normal file
View 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.