FpDebug: more range check exceptions / fixed missing begin/end

This commit is contained in:
Martin 2023-04-02 20:35:34 +02:00
parent 0045ad70a6
commit f0ce562200
3 changed files with 19 additions and 12 deletions

View File

@ -2599,6 +2599,8 @@ var
begin
ASubStr := '';
Result := True;
if ALen <= 0 then
exit;
t := TypeInfo;
if t = nil then
@ -2629,7 +2631,7 @@ begin
then
ALen := MemManager.MemLimits.MaxStringLen;
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
Addr.Address := Addr.Address + AStartIndex - 1;
{$POP}
if not ( (MemManager.SetLength(ASubStr, ALen)) and
@ -2702,7 +2704,7 @@ begin
then
ALen := MemManager.MemLimits.MaxStringLen * 2;
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
Addr.Address := Addr.Address + (AStartIndex - 1) * 2;
{$POP}
if not ( (MemManager.SetLength(ASubStr, ALen)) and
@ -4093,6 +4095,8 @@ begin
// TODO: if FValueDone, and covers selected range, then use FValue;
ASubStr := '';
Result := True;
if ALen <= 0 then
exit;
dec(AStartIndex);
if AStartIndex < 0 then begin // not supported, return partial

View File

@ -1113,7 +1113,7 @@ begin
exit;
while AParentClassIndex > 0 do begin
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
VmtAddr.Address := VmtAddr.Address + TDBGPtr(2 * ASizeOfAddr);
{$POP}
A := VmtAddr;
@ -1142,7 +1142,7 @@ begin
dec(AParentClassIndex);
end;
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
VmtAddr.Address := VmtAddr.Address + TDBGPtr(3 * ASizeOfAddr);
{$POP}
@ -1179,7 +1179,7 @@ begin
if AUnitName <> nil then begin
// get vTypeInfo
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
VmtAddr.Address := VmtAddr.Address + TDBGPtr(4 * ASizeOfAddr);
{$POP}
@ -1193,7 +1193,7 @@ begin
//inc(Pointer(classtypeinfo), PByte(Pointer(classtypeinfo)+1)^ + 2);
A := ClassNameAddr;
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
A.Address := A.Address + 1;
{$POP}
if not AContext.ReadUnsignedInt(A, SizeVal(1), NameLen) then begin
@ -1201,7 +1201,7 @@ begin
AContext.ClearLastMemError;
exit;
end;
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
ClassNameAddr.Address := ClassNameAddr.Address + TDBGPtr(NameLen + 2) + TDBGPtr(2 * ASizeOfAddr + 2);
if (ACompilerVersion >= $030300) then
ClassNameAddr.Address := ClassNameAddr.Address + TDBGPtr(ASizeOfAddr);
@ -1674,7 +1674,7 @@ begin
CalcBounds;
if FHighBound < FLowBound then
exit; // empty string
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
FullLen := FHighBound-FLowBound+1;
{$POP}
@ -1705,10 +1705,12 @@ begin
then
ALen := MemManager.MemLimits.MaxStringLen;
if ALen <= 0 then
exit;
t := TypeInfo;
if t.Kind = skWideString then begin
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
Addr.Address := Addr.Address + (AStartIndex - 1) * 2;
{$POP}
if not ( (MemManager.SetLength(WResult, ALen)) and
@ -1720,7 +1722,7 @@ begin
end else
if Addr.Address = Address.Address + 1 then begin
// shortstring
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
Addr.Address := Addr.Address + AStartIndex - 1;
{$POP}
if not ( (MemManager.SetLength(ASubStr, ALen)) and
@ -1782,7 +1784,7 @@ begin
CalcBounds;
if FHighBound < FLowBound then
exit; // empty string
{$PUSH}{$Q-}
{$PUSH}{$Q-}{$R-}
Len := FHighBound-FLowBound+1;
{$POP}

View File

@ -4990,9 +4990,10 @@ function TFpPasParserValueSlicedArray.GetMember(AIndex: Int64): TFpValue;
begin
if SlicePart.FCurrentIndex = AIndex then begin
Result := FArraySlice.Items[0].ResultValue;
if Result <> nil then
if Result <> nil then begin
Result.AddReference;
Result.Reset;
end;
exit;
end;