mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 16:40:25 +02:00
rtl: correct error check for encoding methods arguments
git-svn-id: trunk@19399 -
This commit is contained in:
parent
af03a73af2
commit
80a615c542
@ -146,7 +146,7 @@ end;
|
||||
function TEncoding.GetByteCount(const Chars: TUnicodeCharArray; CharIndex,
|
||||
CharCount: Integer): Integer;
|
||||
begin
|
||||
if (CharCount < 0) or (Length(Chars) <= CharCount + CharIndex) then
|
||||
if (CharCount < 0) or (Length(Chars) < CharCount + CharIndex) then
|
||||
raise EEncodingError.CreateFmt(SInvalidCount, [CharCount]);
|
||||
if (CharIndex < 0) then
|
||||
raise EEncodingError.CreateFmt(SCharacterIndexOutOfBounds, [CharIndex]);
|
||||
@ -176,7 +176,7 @@ end;
|
||||
function TEncoding.GetBytes(const Chars: TUnicodeCharArray; CharIndex,
|
||||
CharCount: Integer): TBytes;
|
||||
begin
|
||||
if (CharCount < 0) or (Length(Chars) <= CharCount + CharIndex) then
|
||||
if (CharCount < 0) or (Length(Chars) < CharCount + CharIndex) then
|
||||
raise EEncodingError.CreateFmt(SInvalidCount, [CharCount]);
|
||||
if (CharIndex < 0) then
|
||||
raise EEncodingError.CreateFmt(SCharacterIndexOutOfBounds, [CharIndex]);
|
||||
@ -194,7 +194,7 @@ begin
|
||||
raise EEncodingError.Create(SInvalidDestinationArray);
|
||||
if (ByteIndex < 0) or (ByteLen < ByteIndex) then
|
||||
raise EEncodingError.CreateFmt(SInvalidDestinationIndex, [ByteIndex]);
|
||||
if (CharCount < 0) or (Length(Chars) <= CharCount + CharIndex) then
|
||||
if (CharCount < 0) or (Length(Chars) < CharCount + CharIndex) then
|
||||
raise EEncodingError.CreateFmt(SInvalidCount, [CharCount]);
|
||||
if (CharIndex < 0) then
|
||||
raise EEncodingError.CreateFmt(SCharacterIndexOutOfBounds, [CharIndex]);
|
||||
|
Loading…
Reference in New Issue
Block a user