mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 19:19:19 +02:00
Check bounds in SetLength(shortstring).
This commit is contained in:
parent
dc7130d078
commit
fc3d71bba3
@ -19,8 +19,10 @@
|
||||
{$define FPC_HAS_SHORTSTR_SETLENGTH}
|
||||
procedure fpc_Shortstr_SetLength(var s:shortstring;len:SizeInt);[Public,Alias : 'FPC_SHORTSTR_SETLENGTH']; compilerproc;
|
||||
begin
|
||||
if Len>255 then
|
||||
Len:=255;
|
||||
if len<0 then
|
||||
len:=0;
|
||||
if len>high(s) then
|
||||
len:=high(s);
|
||||
s[0]:=chr(len);
|
||||
end;
|
||||
{$endif FPC_HAS_SHORTSTR_SETLENGTH}
|
||||
|
Loading…
Reference in New Issue
Block a user