fcl-passrc: fixed mem leaks

git-svn-id: trunk@39460 -
This commit is contained in:
Mattias Gaertner 2018-07-17 05:33:11 +00:00
parent 14af86bd1c
commit 61c36a008a
4 changed files with 27 additions and 10 deletions

View File

@ -3573,6 +3573,7 @@ begin
sRangeCheckInSetConstructor,[],El);
end;
Result.Add(RangeStart,RangeEnd);
ReleaseEvalValue(Value);
end;
ok:=OnlyConstElements;
finally

View File

@ -7094,6 +7094,7 @@ begin
Item:=PRangeItem(Values[i]);
Dispose(Item);
end;
Values.Free;
end;
end;
@ -19952,13 +19953,17 @@ begin
Range:=Eval(RangeExpr,[refConst]);
if Range=nil then
RaiseNotYetImplemented(20170910210416,RangeExpr);
case Range.Kind of
revkRangeInt:
Result:=TResEvalRangeInt(Range).RangeEnd-TResEvalRangeInt(Range).RangeStart+1;
revkRangeUInt:
Result:=TResEvalRangeUInt(Range).RangeEnd-TResEvalRangeUInt(Range).RangeStart+1;
else
RaiseNotYetImplemented(20170910210554,RangeExpr);
try
case Range.Kind of
revkRangeInt:
Result:=TResEvalRangeInt(Range).RangeEnd-TResEvalRangeInt(Range).RangeStart+1;
revkRangeUInt:
Result:=TResEvalRangeUInt(Range).RangeEnd-TResEvalRangeUInt(Range).RangeStart+1;
else
RaiseNotYetImplemented(20170910210554,RangeExpr);
end;
finally
ReleaseEvalValue(Range);
end;
{$IFDEF VerbosePasResolver}
{AllowWriteln}
@ -20089,7 +20094,6 @@ begin
TResEvalRangeInt(Result).ElKind:=revskInt;
GetIntegerRange(BaseTypeData.BaseType,
TResEvalRangeInt(Result).RangeStart,TResEvalRangeInt(Result).RangeEnd);
exit;
end;
end;
end;

View File

@ -2920,6 +2920,7 @@ begin
TPasElement(AList[i]).Parent:=Self;
GenericTemplateTypes.Add(AList[i]);
end;
AList.Clear;
ObjKind:=okGeneric;
end;
@ -3225,6 +3226,7 @@ begin
ReleaseAndNil(TPasElement(PublicName){$IFDEF CheckPasTreeRefCount},'TPasProcedure.PublicName'{$ENDIF});
ReleaseAndNil(TPasElement(LibraryExpr){$IFDEF CheckPasTreeRefCount},'TPasProcedure.LibraryExpr'{$ENDIF});
ReleaseAndNil(TPasElement(LibrarySymbolName){$IFDEF CheckPasTreeRefCount},'TPasProcedure.LibrarySymbolName'{$ENDIF});
ReleaseAndNil(TPasElement(DispIDExpr){$IFDEF CheckPasTreeRefCount},'TPasProcedure.DispIDExpr'{$ENDIF});
inherited Destroy;
end;
@ -3999,6 +4001,7 @@ begin
TPasElement(AList[i]).Parent:=Self;
GenericTemplateTypes.Add(AList[i]);
end;
AList.Clear;
end;
procedure TPasProcedureType.GetArguments(List : TStrings);

View File

@ -3476,6 +3476,8 @@ begin
ParseExc(nParserGenericClassOrArray,SParserGenericClassOrArray);
end;
finally
for i:=0 to List.Count-1 do
TPasElement(List[i]).Release{$IFDEF CheckPasTreeRefCount}('CreateElement'){$ENDIF};
List.Free;
end;
end;
@ -4058,6 +4060,7 @@ var
NamePos: TPasSourcePos;
OldForceCaret : Boolean;
List : TFPList;
i: Integer;
begin
TypeName := CurTokenString;
@ -4075,7 +4078,12 @@ begin
Result:=ParseType(Parent,NamePos,TypeName,True,List);
finally
Scanner.SetForceCaret(OldForceCaret);
List.Free;
if List<>nil then
begin
for i:=0 to List.Count-1 do
TPasElement(List[i]).Release{$IFDEF CheckPasTreeRefCount}('CreateElement'){$ENDIF};
List.Free;
end;
end;
end;
@ -5868,6 +5876,7 @@ begin
// label mark. todo: check mark identifier in the list of labels
El:=TPasImplLabelMark(CreateElement(TPasImplLabelMark,'', CurBlock,SrcPos));
TPasImplLabelMark(El).LabelId:=TPrimitiveExpr(Left).Value;
ReleaseAndNil(TPasElement(Left){$IFDEF CheckPasTreeRefCount},'CreateElement'{$ENDIF});
CurBlock.AddElement(El);
CmdElem:=TPasImplLabelMark(El);
El:=nil;
@ -5875,7 +5884,7 @@ begin
else
// simple statement (function call)
El:=TPasImplSimple(CreateElement(TPasImplSimple,'',CurBlock,SrcPos));
TPasImplSimple(El).expr:=Left;
TPasImplSimple(El).Expr:=Left;
Left:=nil;
AddStatement(El);
El:=nil;