From 121a857af8189ae5c88e679f5a2a0dc4d4f10237 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Thu, 15 Dec 2016 13:47:26 +0000 Subject: [PATCH] * fix for Mantis #31118: applied patch by Maciej Izak to fix usage of wrong variable + added test git-svn-id: trunk@35133 - --- .gitattributes | 1 + rtl/inc/rtti.inc | 2 +- tests/test/trtti11.pp | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/test/trtti11.pp diff --git a/.gitattributes b/.gitattributes index b266e4ebca..03f48c1fd6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13007,6 +13007,7 @@ tests/test/trstr7.pp svneol=native#text/plain tests/test/trstr8.pp svneol=native#text/plain tests/test/trtti1.pp svneol=native#text/plain tests/test/trtti10.pp svneol=native#text/pascal +tests/test/trtti11.pp svneol=native#text/pascal tests/test/trtti2.pp svneol=native#text/plain tests/test/trtti3.pp svneol=native#text/plain tests/test/trtti4.pp svneol=native#text/plain diff --git a/rtl/inc/rtti.inc b/rtl/inc/rtti.inc index 7d2c4ef161..3a31d3c99a 100644 --- a/rtl/inc/rtti.inc +++ b/rtl/inc/rtti.inc @@ -116,7 +116,7 @@ begin { check terminator, maybe we are already in init table } if Assigned(PRecordInfoInit(typeInfo)^.Terminator) then { point to more optimal initrtti } - result:=PRecordInfoFull(result)^.InitTable; + result:=PRecordInfoFull(typeInfo)^.InitTable; {$endif VER3_0} end; diff --git a/tests/test/trtti11.pp b/tests/test/trtti11.pp new file mode 100644 index 0000000000..5ae007fdaf --- /dev/null +++ b/tests/test/trtti11.pp @@ -0,0 +1,28 @@ +program trtti11; + +{$MODE DELPHI} + +uses + SysUtils; + +type + PFoo = ^TFoo; + TFoo = packed record + public + F: Integer; + S: string; + end; + +var + PF: PFoo; +begin + try + GetMem(PF, SizeOf(TFoo)); + InitializeArray(PF, TypeInfo(TFoo), 1); + PF.S := 'foo'; + FinalizeArray(PF, TypeInfo(TFoo), 1); + FreeMem(PF); + except + Halt(1); + end; +end.