浏览代码

* protect the destructors of tabstractrecordsymtable and twithsymtable against executing when called with a refcount > 1 (this fixes Mantis #34210)
+ added simplified test

git-svn-id: trunk@39693 -

svenbarth 7 年之前
父节点
当前提交
072699d38a
共有 3 个文件被更改,包括 27 次插入2 次删除
  1. 1 0
      .gitattributes
  2. 5 2
      compiler/symtable.pas
  3. 21 0
      tests/tbs/tb0650.pp

+ 1 - 0
.gitattributes

@@ -11596,6 +11596,7 @@ tests/tbs/tb0646a.pp svneol=native#text/pascal
 tests/tbs/tb0646b.pp svneol=native#text/pascal
 tests/tbs/tb0648.pp svneol=native#text/pascal
 tests/tbs/tb0649.pp -text svneol=native#text/pascal
+tests/tbs/tb0650.pp svneol=native#text/pascal
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tb610.pp svneol=native#text/pascal
 tests/tbs/tb613.pp svneol=native#text/plain

+ 5 - 2
compiler/symtable.pas

@@ -1179,9 +1179,10 @@ implementation
         mopofs : pmanagementoperator_offset_entry;
         i : longint;
       begin
+        if refcount>1 then
+          exit;
 {$ifdef llvm}
-        if refcount=1 then
-          fllvmst.free;
+        fllvmst.free;
 {$endif llvm}
         for mop in tmanagementoperator do
           begin
@@ -2713,6 +2714,8 @@ implementation
 
     destructor twithsymtable.destroy;
       begin
+        if refcount>1 then
+          exit;
         withrefnode.free;
         { Disable SymList because we don't Own it }
         SymList:=nil;

+ 21 - 0
tests/tbs/tb0650.pp

@@ -0,0 +1,21 @@
+unit tb0650;
+
+{$mode objfpc}{$H+}
+
+interface
+
+type
+  TTest = record
+    SomeField: String;
+  end;
+
+  TTestType = type TTest;
+
+  TTestClass = class
+    fField: TTestType;
+  end;
+
+implementation
+
+end.
+