mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 05:09:19 +02:00
* fixed copy where size+index could be < 0
This commit is contained in:
parent
a352b586ca
commit
4c3df986f0
@ -455,8 +455,10 @@ var
|
|||||||
begin
|
begin
|
||||||
ResultAddress:=Nil;
|
ResultAddress:=Nil;
|
||||||
dec(index);
|
dec(index);
|
||||||
{ Check Size. Accounts for Zero-length S }
|
{ Check Size. Accounts for Zero-length S, the double check is needed because
|
||||||
if Length(S)<Index+Size then
|
Size can be maxint and will get <0 when adding index }
|
||||||
|
if (Size>Length(S)) or
|
||||||
|
(Index+Size>Length(S)) then
|
||||||
Size:=Length(S)-Index;
|
Size:=Length(S)-Index;
|
||||||
If Size>0 then
|
If Size>0 then
|
||||||
begin
|
begin
|
||||||
@ -502,7 +504,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
pos := j;
|
pos := j;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -623,16 +624,19 @@ begin
|
|||||||
S:=Temp;
|
S:=Temp;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function StringOfChar(c : char;l : longint) : AnsiString;
|
|
||||||
|
|
||||||
begin
|
Function StringOfChar(c : char;l : longint) : AnsiString;
|
||||||
SetLength(StringOfChar,l);
|
begin
|
||||||
FillChar(Pointer(StringOfChar)^,Length(StringOfChar),c);
|
SetLength(StringOfChar,l);
|
||||||
end;
|
FillChar(Pointer(StringOfChar)^,Length(StringOfChar),c);
|
||||||
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.33 1999-10-27 14:27:49 florian
|
Revision 1.34 1999-11-02 23:57:54 peter
|
||||||
|
* fixed copy where size+index could be < 0
|
||||||
|
|
||||||
|
Revision 1.33 1999/10/27 14:27:49 florian
|
||||||
* StringOfChar fixed, how can be a bug in two lines of code ?????
|
* StringOfChar fixed, how can be a bug in two lines of code ?????
|
||||||
|
|
||||||
Revision 1.32 1999/10/27 14:17:20 florian
|
Revision 1.32 1999/10/27 14:17:20 florian
|
||||||
|
Loading…
Reference in New Issue
Block a user