mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-23 22:59:21 +02:00
codetools: fixed mem leak when searching for proc expr lists
git-svn-id: trunk@13492 -
This commit is contained in:
parent
e671bbc042
commit
82e314a897
@ -2862,12 +2862,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
OldContextNode:=Params.ContextNode;
|
OldContextNode:=Params.ContextNode;
|
||||||
if OldContextNode.FirstChild<>nil then begin
|
if OldContextNode.FirstChild<>nil then begin
|
||||||
try
|
|
||||||
Params.ContextNode:=CurContextNode;
|
Params.ContextNode:=CurContextNode;
|
||||||
Result:=FindEnumInContext(Params);
|
Result:=FindEnumInContext(Params);
|
||||||
finally
|
|
||||||
Params.ContextNode:=OldContextNode;
|
Params.ContextNode:=OldContextNode;
|
||||||
end;
|
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
end;
|
end;
|
||||||
CurContextNode:=CurContextNode.NextBrother;
|
CurContextNode:=CurContextNode.NextBrother;
|
||||||
@ -5048,15 +5045,11 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
// the system unit name itself is searched -> rename searched identifier
|
// the system unit name itself is searched -> rename searched identifier
|
||||||
Params.Save(OldInput);
|
Params.Save(OldInput);
|
||||||
try
|
|
||||||
Params.SetIdentifier(Self,PChar(Pointer(SystemAlias)),nil);
|
Params.SetIdentifier(Self,PChar(Pointer(SystemAlias)),nil);
|
||||||
Result:=FindIdentifierInUsedUnit(SystemAlias,Params);
|
Result:=FindIdentifierInUsedUnit(SystemAlias,Params);
|
||||||
finally
|
|
||||||
// ! always reset input, because the string SystemAlias is freed !
|
|
||||||
Params.Load(OldInput,true);
|
Params.Load(OldInput,true);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -6529,6 +6522,7 @@ var
|
|||||||
OldInput: TFindDeclarationInput;
|
OldInput: TFindDeclarationInput;
|
||||||
CurCompatibilityList: TTypeCompatibilityList;
|
CurCompatibilityList: TTypeCompatibilityList;
|
||||||
CompListSize: integer;
|
CompListSize: integer;
|
||||||
|
NewExprInputList: TExprTypeList;
|
||||||
begin
|
begin
|
||||||
// the search has found an identifier with the right name
|
// the search has found an identifier with the right name
|
||||||
{$IFDEF ShowFoundIdentifier}
|
{$IFDEF ShowFoundIdentifier}
|
||||||
@ -6617,10 +6611,12 @@ begin
|
|||||||
Params.ContextNode:=StartContextNode;
|
Params.ContextNode:=StartContextNode;
|
||||||
Params.OnIdentifierFound:=@Params.IdentifierTool.CheckSrcIdentifier;
|
Params.OnIdentifierFound:=@Params.IdentifierTool.CheckSrcIdentifier;
|
||||||
Params.IdentifierTool.ReadNextAtom;
|
Params.IdentifierTool.ReadNextAtom;
|
||||||
Params.FoundProc^.ExprInputList:=
|
NewExprInputList:=
|
||||||
Params.IdentifierTool.CreateParamExprListFromStatement(
|
Params.IdentifierTool.CreateParamExprListFromStatement(
|
||||||
Params.IdentifierTool.CurPos.EndPos,Params);
|
Params.IdentifierTool.CurPos.EndPos,Params);
|
||||||
Params.Load(OldInput,true);
|
Params.Load(OldInput,true);
|
||||||
|
FreeAndNil(Params.FoundProc^.ExprInputList);
|
||||||
|
Params.FoundProc^.ExprInputList:=NewExprInputList;
|
||||||
end
|
end
|
||||||
else if (StartContextNode.Desc in [ctnProcedureHead,ctnProcedure])
|
else if (StartContextNode.Desc in [ctnProcedureHead,ctnProcedure])
|
||||||
then begin
|
then begin
|
||||||
@ -6630,9 +6626,11 @@ begin
|
|||||||
' Creating Input Expression List for proc node ...'
|
' Creating Input Expression List for proc node ...'
|
||||||
);
|
);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Params.FoundProc^.ExprInputList:=
|
NewExprInputList:=
|
||||||
Params.IdentifierTool.CreateParamExprListFromProcNode(
|
Params.IdentifierTool.CreateParamExprListFromProcNode(
|
||||||
StartContextNode,Params);
|
StartContextNode,Params);
|
||||||
|
FreeAndNil(Params.FoundProc^.ExprInputList);
|
||||||
|
Params.FoundProc^.ExprInputList:=NewExprInputList;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -8333,7 +8331,7 @@ end;
|
|||||||
|
|
||||||
procedure TExprTypeList.Grow;
|
procedure TExprTypeList.Grow;
|
||||||
begin
|
begin
|
||||||
Capacity:=Capacity+5;
|
Capacity:=Capacity*2+4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TExprTypeList.Add(const ExprType: TExpressionType);
|
procedure TExprTypeList.Add(const ExprType: TExpressionType);
|
||||||
|
Loading…
Reference in New Issue
Block a user