mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 14:59:30 +02:00
codetools: fixed range check
git-svn-id: trunk@48260 -
This commit is contained in:
parent
5bda463520
commit
9fd34c07cf
@ -2313,12 +2313,15 @@ begin
|
||||
end;
|
||||
|
||||
function TCustomCodeTool.IsPCharInSrc(ACleanPos: PChar): boolean;
|
||||
var NewPos: integer;
|
||||
// Note: the ending #0 is a valid position
|
||||
var
|
||||
p: PChar;
|
||||
begin
|
||||
Result:=false;
|
||||
if Src='' then exit;
|
||||
NewPos:=PtrInt(PtrUInt(ACleanPos))-PtrInt(PtrUInt(@Src[1]))+1;
|
||||
if (NewPos<1) or (NewPos>SrcLen) then exit;
|
||||
p:=PChar(Src);
|
||||
if p>ACleanPos then exit;
|
||||
if ACleanPos>p+SrcLen then exit;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user