rtl: correct error check for encoding methods arguments

git-svn-id: trunk@19399 -
This commit is contained in:
paul 2011-10-07 05:56:02 +00:00
parent af03a73af2
commit 80a615c542

View File

@ -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]);