소스 검색

* fixed crash when current_module becomes nil

peter 23 년 전
부모
커밋
37bb42694b
2개의 변경된 파일67개의 추가작업 그리고 55개의 파일을 삭제
  1. 61 53
      compiler/parser.pas
  2. 6 2
      compiler/scanner.pas

+ 61 - 53
compiler/parser.pas

@@ -461,20 +461,23 @@ implementation
          it's the default to release the trees }
          it's the default to release the trees }
          codegen_donemodule;
          codegen_donemodule;
 
 
-         { free ppu }
-         if assigned(tppumodule(current_module).ppufile) then
+         if assigned(current_module) then
           begin
           begin
-            tppumodule(current_module).ppufile.free;
-            tppumodule(current_module).ppufile:=nil;
-          end;
+            { free ppu }
+            if assigned(tppumodule(current_module).ppufile) then
+             begin
+               tppumodule(current_module).ppufile.free;
+               tppumodule(current_module).ppufile:=nil;
+             end;
 
 
-         { free scanner }
-         if assigned(current_module.scanner) then
-          begin
-            if current_scanner=tscannerfile(current_module.scanner) then
-              current_scanner:=nil;
-            tscannerfile(current_module.scanner).free;
-            current_module.scanner:=nil;
+            { free scanner }
+            if assigned(current_module.scanner) then
+             begin
+               if current_scanner=tscannerfile(current_module.scanner) then
+                 current_scanner:=nil;
+               tscannerfile(current_module.scanner).free;
+               current_module.scanner:=nil;
+             end;
           end;
           end;
 
 
          if (compile_level>1) then
          if (compile_level>1) then
@@ -540,53 +543,55 @@ implementation
            end
            end
          else
          else
            begin
            begin
-              parser_current_file:='';
-           end;
-
-       { Shut down things when the last file is compiled }
-         if (compile_level=1) then
-          begin
-          { Close script }
-            if (not AsmRes.Empty) then
-             begin
-               Message1(exec_i_closing_script,AsmRes.Fn);
-               AsmRes.WriteToDisk;
-             end;
+             parser_current_file:='';
+             { Shut down things when the last file is compiled }
+             if (compile_level=1) then
+              begin
+                { Close script }
+                if (not AsmRes.Empty) then
+                 begin
+                   Message1(exec_i_closing_script,AsmRes.Fn);
+                   AsmRes.WriteToDisk;
+                 end;
 
 
 {$ifdef USEEXCEPT}
 {$ifdef USEEXCEPT}
-            if not longjump_used then
+                if not longjump_used then
 {$endif USEEXCEPT}
 {$endif USEEXCEPT}
-            { do not create browsers on errors !! }
-            if status.errorcount=0 then
-              begin
-{$ifdef BrowserLog}
-              { Write Browser Log }
-              if (cs_browser_log in aktglobalswitches) and
-                 (cs_browser in aktmoduleswitches) then
                  begin
                  begin
-                 if browserlog.elements_to_list.empty then
-                   begin
-                   Message1(parser_i_writing_browser_log,browserlog.Fname);
-                   WriteBrowserLog;
-                   end
-                 else
-                  browserlog.list_elements;
-                 end;
+                   { do not create browsers on errors !! }
+                   if status.errorcount=0 then
+                    begin
+{$ifdef BrowserLog}
+                      { Write Browser Log }
+                      if (cs_browser_log in aktglobalswitches) and
+                         (cs_browser in aktmoduleswitches) then
+                       begin
+                         if browserlog.elements_to_list.empty then
+                          begin
+                            Message1(parser_i_writing_browser_log,browserlog.Fname);
+                            WriteBrowserLog;
+                          end
+                         else
+                          browserlog.list_elements;
+                       end;
 {$endif BrowserLog}
 {$endif BrowserLog}
 
 
-                 { Write Browser Collections }
-                 do_extractsymbolinfo{$ifdef FPC}(){$endif};
-              end;
-
-            if current_module.in_second_compile then
-              begin
-                current_module.in_second_compile:=false;
-                current_module.in_compile:=true;
-              end
-            else
-              current_module.in_compile:=false;
+                      { Write Browser Collections }
+                      do_extractsymbolinfo{$ifdef FPC}(){$endif};
+                    end;
+                 end;
 
 
-          end;
+{$ifdef dummy}
+                if current_module.in_second_compile then
+                 begin
+                   current_module.in_second_compile:=false;
+                   current_module.in_compile:=true;
+                 end
+                else
+                 current_module.in_compile:=false;
+{$endif dummy}
+              end;
+           end;
 
 
          dec(compile_level);
          dec(compile_level);
          compiled_module:=old_compiled_module;
          compiled_module:=old_compiled_module;
@@ -599,7 +604,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.43  2002-08-18 19:58:28  peter
+  Revision 1.44  2002-09-05 19:27:06  peter
+    * fixed crash when current_module becomes nil
+
+  Revision 1.43  2002/08/18 19:58:28  peter
     * more current_scanner fixes
     * more current_scanner fixes
 
 
   Revision 1.42  2002/08/16 15:31:08  peter
   Revision 1.42  2002/08/16 15:31:08  peter

+ 6 - 2
compiler/scanner.pas

@@ -936,7 +936,8 @@ implementation
 
 
     destructor tscannerfile.destroy;
     destructor tscannerfile.destroy;
       begin
       begin
-        if (not current_module.in_second_load) and
+        if assigned(current_module) and
+           (not current_module.in_second_load) and
            (status.errorcount=0) then
            (status.errorcount=0) then
           checkpreprocstack
           checkpreprocstack
         else
         else
@@ -2780,7 +2781,10 @@ exit_label:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.45  2002-09-05 14:17:27  pierre
+  Revision 1.46  2002-09-05 19:27:05  peter
+    * fixed crash when current_module becomes nil
+
+  Revision 1.45  2002/09/05 14:17:27  pierre
    * fix for bug 2004 merged
    * fix for bug 2004 merged
 
 
   Revision 1.44  2002/08/12 16:46:04  peter
   Revision 1.44  2002/08/12 16:46:04  peter