* don't take the address of element 0 of a dynamic array in

tcallparanode.copy_value_by_ref_para() if the array is empty
    (mantis #30007)

git-svn-id: trunk@33595 -
This commit is contained in:
Jonas Maebe 2016-05-01 12:35:09 +00:00
parent 1feb062f7d
commit 130d9fee91
3 changed files with 32 additions and 7 deletions

1
.gitattributes vendored
View File

@ -15038,6 +15038,7 @@ tests/webtbs/tw29958.pp svneol=native#text/pascal
tests/webtbs/tw2998.pp svneol=native#text/plain
tests/webtbs/tw2999.pp svneol=native#text/plain
tests/webtbs/tw29992.pp svneol=native#text/plain
tests/webtbs/tw30007.pp svneol=native#text/plain
tests/webtbs/tw30030.pp svneol=native#text/pascal
tests/webtbs/tw30035.pp svneol=native#text/plain
tests/webtbs/tw30035a.pp svneol=native#text/plain

View File

@ -303,7 +303,7 @@ implementation
verbose,globals,
symconst,defutil,defcmp,
htypechk,pass_1,
ncnv,nld,ninl,nadd,ncon,nmem,nset,nobjc,
ncnv,nflw,nld,ninl,nadd,ncon,nmem,nset,nobjc,
ngenutil,objcutil,
procinfo,cpuinfo,
wpobase;
@ -765,6 +765,12 @@ implementation
{ move(para,temp,sizeof(arr)) (no "left.getcopy" below because
we replace left afterwards) }
addstatement(initstat,
cifnode.create_internal(
caddnode.create_internal(
unequaln,
arraysize.getcopy,
genintconstnode(0)
),
ccallnode.createintern('MOVE',
ccallparanode.create(
arraysize,
@ -775,6 +781,8 @@ implementation
)
)
)
),
nil
)
);
{ no reference count increases, that's still done on the callee

16
tests/webtbs/tw30007.pp Normal file
View File

@ -0,0 +1,16 @@
program project6;
{$r+}
function LinesToText(Lines: array of String): String;
begin
end;
var
SomeLines: array of String;
begin
SetLength(SomeLines,1);
LinesToText(SomeLines); // <-- ok
SetLength(SomeLines,0);
LinesToText(SomeLines); // <-- range error
end.