Просмотр исходного кода

* Win64 SEH: when creating a finalization procedure, put its def into the same symtable with sym. By default, defs are added into symtablestack.top, which may be set to something temporary like exceptsymtable. In such cases it is possible that def is destroyed before sym, leaving sym with invalid pointers.

git-svn-id: trunk@26077 -
sergei 11 лет назад
Родитель
Сommit
3ce0b33302
1 измененных файлов с 10 добавлено и 1 удалено
  1. 10 1
      compiler/x86_64/nx64flw.pas

+ 10 - 1
compiler/x86_64/nx64flw.pas

@@ -143,6 +143,7 @@ function create_pd: tprocdef;
   var
     st:TSymTable;
     checkstack: psymtablestackitem;
+    oldsymtablestack: tsymtablestack;
     sym:tprocsym;
   begin
     { get actual procedure symtable (skip withsymtables, etc.) }
@@ -155,8 +156,16 @@ function create_pd: tprocdef;
             break;
           checkstack:=checkstack^.next;
       end;
-    { Create a nested procedure, even from main_program_level. }
+    { Create a nested procedure, even from main_program_level.
+      Furthermore, force procdef and procsym into the same symtable
+      (by default, defs are registered with symtablestack.top which may be
+      something temporary like exceptsymtable - in that case, procdef can be
+      destroyed before procsym, leaving invalid pointers). }
+    oldsymtablestack:=symtablestack;
+    symtablestack:=nil;
     result:=tprocdef.create(max(normal_function_level,st.symtablelevel)+1);
+    symtablestack:=oldsymtablestack;
+    st.insertdef(result);
     result.struct:=current_procinfo.procdef.struct;
     result.proctypeoption:=potype_exceptfilter;
     handle_calling_convention(result);