* don't increase refcounts for variants assigned to (ti_)const nodes, fixes

memory leak after r34288 and should have been done as part of r34287
    (mantis )

git-svn-id: trunk@34440 -
This commit is contained in:
Jonas Maebe 2016-09-06 21:28:34 +00:00
parent 26f6d2f39d
commit 2d051f89f7
3 changed files with 39 additions and 0 deletions
.gitattributes
compiler
tests/test/units/variants

1
.gitattributes vendored
View File

@ -13399,6 +13399,7 @@ tests/test/units/variants/tcustomvariant.pp svneol=native#text/plain
tests/test/units/variants/tvararrayofintf.pp svneol=native#text/plain
tests/test/units/variants/tw26370.pp svneol=native#text/plain
tests/test/units/variants/tw27044.pp svneol=native#text/plain
tests/test/units/variants/tw30546.pp svneol=native#text/plain
tests/test/units/windows/twinrawinput32.pp svneol=native#text/plain
tests/test/units/windows/twinrawinput64.pp svneol=native#text/plain
tests/test/uobjc24.pp svneol=native#text/plain

View File

@ -836,6 +836,7 @@ implementation
{ call helpers for variant, they can contain non ref. counted types like
vararrays which must be really copied }
else if (left.resultdef.typ=variantdef) and
not(is_const(left)) and
not(target_info.system in systems_garbage_collected_managed_types) then
begin
{ remove property flag to avoid errors, see comments for }

View File

@ -0,0 +1,37 @@
{ %opt=-gh }
{$mode objfpc}
{$h+}
{$inline on}
uses
variants;
var
vv: variant;
function func: variant; inline;
begin
result:=vv;
end;
function varconstinl(const v: variant): boolean; inline;
begin
result:=v='abc';
end;
function test: boolean; inline;
begin
result:=varconstinl(func);
end;
procedure dotest;
begin
HaltOnNotReleased:=true;
vv:='abc';
if not test then
halt(1);
end;
begin
dotest;
end.