فهرست منبع

* another fix for bug #39758, this time the end of the string

marcoonthegit 3 سال پیش
والد
کامیت
2df9dd9c14
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      rtl/objpas/sysutils/sysencoding.inc

+ 2 - 2
rtl/objpas/sysutils/sysencoding.inc

@@ -327,7 +327,7 @@ function TEncoding.GetByteCount(const S: UnicodeString; CharIndex, CharCount: In
 begin
   if (CharIndex < 1) then
     raise EEncodingError.CreateFmt(SCharacterIndexOutOfBounds, [CharIndex]);
-  if (CharCount < 0) or (Length(S) < CharCount + CharIndex) then
+  if (CharCount < 0) or (Length(S) < CharCount + CharIndex - 1) then
     raise EEncodingError.CreateFmt(SInvalidCount, [CharCount]);
   Result := GetByteCount(@S[CharIndex], CharCount);
 end;
@@ -386,7 +386,7 @@ begin
     raise EEncodingError.CreateFmt(SInvalidDestinationIndex, [ByteIndex]);
   if (CharIndex < 1) then
     raise EEncodingError.CreateFmt(SCharacterIndexOutOfBounds, [CharIndex]);
-  if (CharCount < 0) or (Length(S) < CharCount + CharIndex) then
+  if (CharCount < 0) or (Length(S) < CharCount + CharIndex - 1) then
     raise EEncodingError.CreateFmt(SInvalidCount, [CharCount]);
   Result := GetBytes(@S[CharIndex], CharCount, @Bytes[ByteIndex], ByteLen - ByteIndex);
 end;