mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 11:36:02 +02:00
codetools: fixed range check
git-svn-id: branches/fixes_1_4@48261 -
This commit is contained in:
parent
3fc9fb02c2
commit
bcb439a7ef
@ -2329,12 +2329,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomCodeTool.IsPCharInSrc(ACleanPos: PChar): boolean;
|
function TCustomCodeTool.IsPCharInSrc(ACleanPos: PChar): boolean;
|
||||||
var NewPos: integer;
|
// Note: the ending #0 is a valid position
|
||||||
|
var
|
||||||
|
p: PChar;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if Src='' then exit;
|
if Src='' then exit;
|
||||||
NewPos:=PtrInt(PtrUInt(ACleanPos))-PtrInt(PtrUInt(@Src[1]))+1;
|
p:=PChar(Src);
|
||||||
if (NewPos<1) or (NewPos>SrcLen) then exit;
|
if p>ACleanPos then exit;
|
||||||
|
if ACleanPos>p+SrcLen then exit;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user