fixed memleak on exception

git-svn-id: trunk@9714 -
This commit is contained in:
mattias 2006-08-10 23:01:34 +00:00
parent f863fe8262
commit d6550769d0

View File

@ -6470,6 +6470,7 @@ var ExprType: TExpressionType;
ExprStartPos, ExprEndPos: integer; ExprStartPos, ExprEndPos: integer;
CurIgnoreErrorAfterPos: Integer; CurIgnoreErrorAfterPos: Integer;
OldFlags: TFindDeclarationFlags; OldFlags: TFindDeclarationFlags;
ok: Boolean;
procedure RaiseBracketNotFound; procedure RaiseBracketNotFound;
begin begin
@ -6482,60 +6483,66 @@ begin
'"',copy(Src,StartPos,40),'" Context=',Params.ContextNode.DescAsString); '"',copy(Src,StartPos,40),'" Context=',Params.ContextNode.DescAsString);
{$ENDIF} {$ENDIF}
Result:=TExprTypeList.Create; Result:=TExprTypeList.Create;
MoveCursorToCleanPos(StartPos); ok:=false;
ReadNextAtom; // reads first atom after proc name try
if AtomIsChar('(') then MoveCursorToCleanPos(StartPos);
BracketClose:=')' ReadNextAtom; // reads first atom after proc name
else if AtomIsChar('[') then if AtomIsChar('(') then
BracketClose:=']' BracketClose:=')'
else else if AtomIsChar('[') then
BracketClose:=#0; BracketClose:=']'
if IgnoreErrorAfterValid then else
CurIgnoreErrorAfterPos:=IgnoreErrorAfterCleanedPos BracketClose:=#0;
else if IgnoreErrorAfterValid then
CurIgnoreErrorAfterPos:=-1; CurIgnoreErrorAfterPos:=IgnoreErrorAfterCleanedPos
OldFlags:=Params.Flags; else
if BracketClose<>#0 then begin CurIgnoreErrorAfterPos:=-1;
// read parameter list OldFlags:=Params.Flags;
ReadNextAtom; if BracketClose<>#0 then begin
if not AtomIsChar(BracketClose) then begin // read parameter list
// read all expressions ReadNextAtom;
while true do begin if not AtomIsChar(BracketClose) then begin
ExprStartPos:=CurPos.StartPos; // read all expressions
// read til comma or bracket close while true do begin
repeat ExprStartPos:=CurPos.StartPos;
if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin // read til comma or bracket close
ReadTilBracketClose(true); repeat
end; if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin
ReadTilBracketClose(true);
end;
ReadNextAtom;
if (CurPos.StartPos>SrcLen)
or (CurPos.Flag in [cafRoundBracketClose,cafEdgedBracketClose,cafComma])
then
break;
until false;
ExprEndPos:=CurPos.StartPos;
// find expression type
if (CurIgnoreErrorAfterPos>=ExprStartPos) then
Params.Flags:=Params.Flags-[fdfExceptionOnNotFound];
//DebugLn('TFindDeclarationTool.CreateParamExprListFromStatement CurIgnoreErrorAfterPos=',dbgs(CurIgnoreErrorAfterPos),' ExprStartPos=',dbgs(ExprStartPos));
ExprType:=FindExpressionResultType(Params,ExprStartPos,ExprEndPos);
// add expression type to list
Result.Add(ExprType);
MoveCursorToCleanPos(ExprEndPos);
ReadNextAtom; ReadNextAtom;
if (CurPos.StartPos>SrcLen) if AtomIsChar(BracketClose) then break;
or (CurPos.Flag in [cafRoundBracketClose,cafEdgedBracketClose,cafComma]) if not AtomIsChar(',') then
then RaiseBracketNotFound;
break; ReadNextAtom;
until false; end;
ExprEndPos:=CurPos.StartPos;
// find expression type
if (CurIgnoreErrorAfterPos>=ExprStartPos) then
Params.Flags:=Params.Flags-[fdfExceptionOnNotFound];
//DebugLn('TFindDeclarationTool.CreateParamExprListFromStatement CurIgnoreErrorAfterPos=',dbgs(CurIgnoreErrorAfterPos),' ExprStartPos=',dbgs(ExprStartPos));
ExprType:=FindExpressionResultType(Params,ExprStartPos,ExprEndPos);
// add expression type to list
Result.Add(ExprType);
MoveCursorToCleanPos(ExprEndPos);
ReadNextAtom;
if AtomIsChar(BracketClose) then break;
if not AtomIsChar(',') then
RaiseBracketNotFound;
ReadNextAtom;
end; end;
end; end;
Params.Flags:=OldFlags;
{$IFDEF ShowExprEval}
DebugLn('[TFindDeclarationTool.CreateParamExprListFromStatement] END ',
'ParamCount=',dbgs(Result.Count),' "',copy(Src,StartPos,40),'"');
DebugLn(' ExprList=[',Result.AsString,']');
{$ENDIF}
Ok:=true;
finally
if not Ok then Result.Free;
end; end;
Params.Flags:=OldFlags;
{$IFDEF ShowExprEval}
DebugLn('[TFindDeclarationTool.CreateParamExprListFromStatement] END ',
'ParamCount=',dbgs(Result.Count),' "',copy(Src,StartPos,40),'"');
DebugLn(' ExprList=[',Result.AsString,']');
{$ENDIF}
end; end;
function TFindDeclarationTool.CreateParamExprListFromProcNode( function TFindDeclarationTool.CreateParamExprListFromProcNode(