mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 08:29:28 +02:00
* Clean up mswindows/os2 ARGV release in InternalExit to avoid crash if called twice
git-svn-id: trunk@17702 -
This commit is contained in:
parent
144d4c41f2
commit
0af77f8957
@ -896,10 +896,20 @@ Begin
|
||||
|
||||
{$if defined(MSWINDOWS) or defined(OS2)}
|
||||
{ finally release the heap if possible, especially
|
||||
important for DLLs }
|
||||
for i:=0 to argc do
|
||||
sysfreemem(argv[i]);
|
||||
sysfreemem(argv);
|
||||
important for DLLs.
|
||||
Reset the array to nil, and finally also argv itself to
|
||||
avoid double freeing problem in case this function gets called twice. }
|
||||
if assigned(argv) then
|
||||
begin
|
||||
for i:=0 to argc-1 do
|
||||
if assigned(argv[i]) then
|
||||
begin
|
||||
sysfreemem(argv[i]);
|
||||
argv[i]:=nil;
|
||||
end;
|
||||
sysfreemem(argv);
|
||||
argv:=nil;
|
||||
end;
|
||||
{$endif}
|
||||
{$ifdef LINUX}
|
||||
{sysfreemem already checks for nil}
|
||||
|
Loading…
Reference in New Issue
Block a user