diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index fa048127f5..db8100c437 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -4064,6 +4064,7 @@ procedure TLinkScanner.FindCodeInRange(CleanStartPos, CleanEndPos: integer; UniqueSortedCodeList: TFPList); var ACode: Pointer; LinkIndex: integer; + Link: PSourceLink; begin if (CleanStartPos<1) or (CleanStartPos>CleanEndPos) or (CleanEndPos>CleanedLen+1) or (UniqueSortedCodeList=nil) then exit; @@ -4073,10 +4074,13 @@ begin AddCodeToUniqueList(ACode,UniqueSortedCodeList); repeat inc(LinkIndex); - if (LinkIndex>=LinkCount) or (FLinks[LinkIndex].CleanedPos>CleanEndPos) then + if (LinkIndex>=LinkCount) then exit; - if ACode<>FLinks[LinkIndex].Code then begin - ACode:=FLinks[LinkIndex].Code; + Link:=@FLinks[LinkIndex]; + if (Link^.CleanedPos>CleanEndPos) then + exit; + if (ACode<>Link^.Code) and (Link^.Code<>nil) then begin + ACode:=Link^.Code; AddCodeToUniqueList(ACode,UniqueSortedCodeList); end; until false; diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 4ac5a5df74..474cfe94df 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -3133,7 +3133,6 @@ function TStandardCodeTool.ReplaceWords(IdentList: TStrings; CurSource: string; i: integer; begin - CurSource:=ACode.Source; MaxPos:=length(CurSource); StartPos:=1; // go through all source parts between compiler directives