mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 10:50:31 +02:00
* changed fpc_big_chararray and fpc_big_widechararray from
array[0..1023] into array[0..0], because they're used as dummy return types for the Xstring_to_chararray helpers, and if a smaller array is actually passed as result then having a larger array declared will cause -gt to overwrite other data git-svn-id: trunk@6855 -
This commit is contained in:
parent
2948802fb7
commit
a2c3826281
@ -419,10 +419,15 @@ begin
|
||||
len := length(src);
|
||||
if len > arraysize then
|
||||
len := arraysize;
|
||||
{$r-}
|
||||
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
||||
if len > 0 then
|
||||
move(src[1],fpc_ansistr_to_chararray[0],len);
|
||||
{ fpc_big_chararray is defined as array[0..0], see compproc.inc why }
|
||||
fillchar(fpc_ansistr_to_chararray[len],arraysize-len,0);
|
||||
{$ifdef RangeCheckWasOn}
|
||||
{$r+}
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
||||
|
@ -23,10 +23,13 @@
|
||||
|
||||
{ some dummy types necessary to have generic resulttypes for certain compilerprocs }
|
||||
type
|
||||
{ normally the array shall be maxlongint big, but that will confuse
|
||||
the debugger }
|
||||
fpc_big_chararray = array[0..1023] of char;
|
||||
fpc_big_widechararray = array[0..1023] of widechar;
|
||||
{ normally the array should be maxlongint big, but that will confuse
|
||||
the debugger. The compiler will set the correct size of the array
|
||||
internally. It's now set to 0..0 because when compiling with -gt,
|
||||
the entire array will be trashed, so it must not be defined larger
|
||||
than the minimal size (otherwise we can trash other memory) }
|
||||
fpc_big_chararray = array[0..0] of char;
|
||||
fpc_big_widechararray = array[0..0] of widechar;
|
||||
fpc_small_set = longint;
|
||||
fpc_normal_set = array[0..7] of longint;
|
||||
|
||||
|
@ -769,10 +769,14 @@ begin
|
||||
len := length(src);
|
||||
if len > arraysize then
|
||||
len := arraysize;
|
||||
{$r-}
|
||||
{ make sure we don't access char 1 if length is 0 (JM) }
|
||||
if len > 0 then
|
||||
move(src[1],fpc_shortstr_to_chararray[0],len);
|
||||
fillchar(fpc_shortstr_to_chararray[len],arraysize-len,0);
|
||||
{$ifdef RangeCheckWasOn}
|
||||
{$r+}
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
|
||||
|
@ -676,8 +676,12 @@ begin
|
||||
len := length(temp);
|
||||
if len > arraysize then
|
||||
len := arraysize;
|
||||
{$r-}
|
||||
move(temp[1],fpc_widestr_to_chararray[0],len);
|
||||
fillchar(fpc_widestr_to_chararray[len],arraysize-len,0);
|
||||
{$ifdef RangeCheckWasOn}
|
||||
{$r+}
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
||||
@ -690,10 +694,14 @@ begin
|
||||
len := length(src);
|
||||
if len > arraysize then
|
||||
len := arraysize;
|
||||
{$r-}
|
||||
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
||||
if len > 0 then
|
||||
move(src[1],fpc_widestr_to_widechararray[0],len*SizeOf(WideChar));
|
||||
fillchar(fpc_widestr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
||||
{$ifdef RangeCheckWasOn}
|
||||
{$r+}
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
||||
@ -712,8 +720,12 @@ begin
|
||||
if len > arraysize then
|
||||
len := arraysize;
|
||||
|
||||
{$r-}
|
||||
move(temp[1],fpc_ansistr_to_widechararray[0],len*sizeof(widechar));
|
||||
fillchar(fpc_ansistr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
||||
{$ifdef RangeCheckWasOn}
|
||||
{$r+}
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
function fpc_shortstr_to_widechararray(arraysize: SizeInt; const src: ShortString): fpc_big_widechararray;[public,alias: 'FPC_SHORTSTR_TO_WIDECHARARRAY']; compilerproc;
|
||||
@ -728,8 +740,12 @@ begin
|
||||
len := length(temp);
|
||||
if len > arraysize then
|
||||
len := arraysize;
|
||||
{$r-}
|
||||
move(temp[1],fpc_shortstr_to_widechararray[0],len*sizeof(widechar));
|
||||
fillchar(fpc_shortstr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
||||
{$ifdef RangeCheckWasOn}
|
||||
{$r+}
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
Function fpc_WideStr_Compare(const S1,S2 : WideString): SizeInt;[Public,Alias : 'FPC_WIDESTR_COMPARE']; compilerproc;
|
||||
|
Loading…
Reference in New Issue
Block a user