From 95f93fb4a636c6c1575ae35539e7af84430b2d6e Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 22 Oct 2011 07:25:01 +0000 Subject: [PATCH] codetools: GetPasDocComment: fixed endless loop git-svn-id: trunk@33014 - --- components/codetools/basiccodetools.pas | 11 ++++++----- components/codetools/pascalreadertool.pas | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 86864b1988..b4f7723989 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -1150,7 +1150,10 @@ end; function FindNextComment(const ASource: string; StartPos: integer; MaxPos: integer): integer; // if not found: Result=MaxPos+1 +var + NotFoundPos: Integer; begin + NotFoundPos:=MaxPos+1; if (MaxPos>length(ASource)) or (MaxPos<1) then MaxPos:=length(ASource); Result:=StartPos; @@ -1160,11 +1163,9 @@ begin begin inc(Result); while (Result<=MaxPos) do begin - if (ASource[Result]<>'''') then - inc(Result) - else begin + if (ASource[Result] in ['''',#10,#13]) then break; - end; + inc(Result); end; end; @@ -1182,7 +1183,7 @@ begin end; inc(Result); end; - if Result>MaxPos+1 then Result:=MaxPos+1; + if Result>=MaxPos+1 then Result:=NotFoundPos; end; procedure FindCommentsInRange(const Src: string; StartPos, EndPos: integer; diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index 776ab5d5ae..6241016ada 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -2994,6 +2994,7 @@ function TPascalReaderTool.GetPasDocComments(Node: TCodeTreeNode; begin // read comments (start in front of node) //DebugLn(['TPascalReaderTool.GetPasDocComments Scan Src=',copy(Src,StartPos,EndPos-StartPos)]); + if EndPos>SrcLen then EndPos:=SrcLen+1; p:=FindLineEndOrCodeInFrontOfPosition(StartPos,true); while p