mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 12:10:45 +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);
|
len := length(src);
|
||||||
if len > arraysize then
|
if len > arraysize then
|
||||||
len := arraysize;
|
len := arraysize;
|
||||||
|
{$r-}
|
||||||
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
||||||
if len > 0 then
|
if len > 0 then
|
||||||
move(src[1],fpc_ansistr_to_chararray[0],len);
|
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);
|
fillchar(fpc_ansistr_to_chararray[len],arraysize-len,0);
|
||||||
|
{$ifdef RangeCheckWasOn}
|
||||||
|
{$r+}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,10 +23,13 @@
|
|||||||
|
|
||||||
{ some dummy types necessary to have generic resulttypes for certain compilerprocs }
|
{ some dummy types necessary to have generic resulttypes for certain compilerprocs }
|
||||||
type
|
type
|
||||||
{ normally the array shall be maxlongint big, but that will confuse
|
{ normally the array should be maxlongint big, but that will confuse
|
||||||
the debugger }
|
the debugger. The compiler will set the correct size of the array
|
||||||
fpc_big_chararray = array[0..1023] of char;
|
internally. It's now set to 0..0 because when compiling with -gt,
|
||||||
fpc_big_widechararray = array[0..1023] of widechar;
|
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_small_set = longint;
|
||||||
fpc_normal_set = array[0..7] of longint;
|
fpc_normal_set = array[0..7] of longint;
|
||||||
|
|
||||||
|
@ -769,10 +769,14 @@ begin
|
|||||||
len := length(src);
|
len := length(src);
|
||||||
if len > arraysize then
|
if len > arraysize then
|
||||||
len := arraysize;
|
len := arraysize;
|
||||||
|
{$r-}
|
||||||
{ make sure we don't access char 1 if length is 0 (JM) }
|
{ make sure we don't access char 1 if length is 0 (JM) }
|
||||||
if len > 0 then
|
if len > 0 then
|
||||||
move(src[1],fpc_shortstr_to_chararray[0],len);
|
move(src[1],fpc_shortstr_to_chararray[0],len);
|
||||||
fillchar(fpc_shortstr_to_chararray[len],arraysize-len,0);
|
fillchar(fpc_shortstr_to_chararray[len],arraysize-len,0);
|
||||||
|
{$ifdef RangeCheckWasOn}
|
||||||
|
{$r+}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
|
{$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
|
||||||
|
@ -676,8 +676,12 @@ begin
|
|||||||
len := length(temp);
|
len := length(temp);
|
||||||
if len > arraysize then
|
if len > arraysize then
|
||||||
len := arraysize;
|
len := arraysize;
|
||||||
|
{$r-}
|
||||||
move(temp[1],fpc_widestr_to_chararray[0],len);
|
move(temp[1],fpc_widestr_to_chararray[0],len);
|
||||||
fillchar(fpc_widestr_to_chararray[len],arraysize-len,0);
|
fillchar(fpc_widestr_to_chararray[len],arraysize-len,0);
|
||||||
|
{$ifdef RangeCheckWasOn}
|
||||||
|
{$r+}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -690,10 +694,14 @@ begin
|
|||||||
len := length(src);
|
len := length(src);
|
||||||
if len > arraysize then
|
if len > arraysize then
|
||||||
len := arraysize;
|
len := arraysize;
|
||||||
|
{$r-}
|
||||||
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
{ make sure we don't try to access element 1 of the ansistring if it's nil }
|
||||||
if len > 0 then
|
if len > 0 then
|
||||||
move(src[1],fpc_widestr_to_widechararray[0],len*SizeOf(WideChar));
|
move(src[1],fpc_widestr_to_widechararray[0],len*SizeOf(WideChar));
|
||||||
fillchar(fpc_widestr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
fillchar(fpc_widestr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
||||||
|
{$ifdef RangeCheckWasOn}
|
||||||
|
{$r+}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -712,8 +720,12 @@ begin
|
|||||||
if len > arraysize then
|
if len > arraysize then
|
||||||
len := arraysize;
|
len := arraysize;
|
||||||
|
|
||||||
|
{$r-}
|
||||||
move(temp[1],fpc_ansistr_to_widechararray[0],len*sizeof(widechar));
|
move(temp[1],fpc_ansistr_to_widechararray[0],len*sizeof(widechar));
|
||||||
fillchar(fpc_ansistr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
fillchar(fpc_ansistr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
||||||
|
{$ifdef RangeCheckWasOn}
|
||||||
|
{$r+}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function fpc_shortstr_to_widechararray(arraysize: SizeInt; const src: ShortString): fpc_big_widechararray;[public,alias: 'FPC_SHORTSTR_TO_WIDECHARARRAY']; compilerproc;
|
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);
|
len := length(temp);
|
||||||
if len > arraysize then
|
if len > arraysize then
|
||||||
len := arraysize;
|
len := arraysize;
|
||||||
|
{$r-}
|
||||||
move(temp[1],fpc_shortstr_to_widechararray[0],len*sizeof(widechar));
|
move(temp[1],fpc_shortstr_to_widechararray[0],len*sizeof(widechar));
|
||||||
fillchar(fpc_shortstr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
fillchar(fpc_shortstr_to_widechararray[len],(arraysize-len)*SizeOf(WideChar),0);
|
||||||
|
{$ifdef RangeCheckWasOn}
|
||||||
|
{$r+}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function fpc_WideStr_Compare(const S1,S2 : WideString): SizeInt;[Public,Alias : 'FPC_WIDESTR_COMPARE']; compilerproc;
|
Function fpc_WideStr_Compare(const S1,S2 : WideString): SizeInt;[Public,Alias : 'FPC_WIDESTR_COMPARE']; compilerproc;
|
||||||
|
Loading…
Reference in New Issue
Block a user