Browse Source

* Fixed last known access violations

git-svn-id: trunk@21942 -
michael 13 years ago
parent
commit
1c894ba71d
2 changed files with 9 additions and 3 deletions
  1. 6 1
      packages/fcl-passrc/src/pastree.pp
  2. 3 2
      packages/fcl-passrc/src/pparser.pp

+ 6 - 1
packages/fcl-passrc/src/pastree.pp

@@ -2705,6 +2705,8 @@ end;
 
 procedure TPasImplCaseOf.AddElement(Element: TPasImplElement);
 begin
+  if (ElseBranch<>Nil) and (Element=ElseBranch) then
+    ElseBranch.AddRef;
   inherited AddElement(Element);
 end;
 
@@ -2747,7 +2749,7 @@ begin
     begin
     Body:=Element;
     Body.AddRef;
-    end;
+    end
 end;
 
 procedure TPasImplCaseStatement.AddExpression(const Expr: string);
@@ -2775,7 +2777,10 @@ procedure TPasImplWithDo.AddElement(Element: TPasImplElement);
 begin
   inherited AddElement(Element);
   if Body=nil then
+    begin
     Body:=Element;
+    Body.AddRef;
+    end;
 end;
 
 procedure TPasImplWithDo.AddExpression(const Expression: string);

+ 3 - 2
packages/fcl-passrc/src/pparser.pp

@@ -3160,7 +3160,9 @@ begin
           tkelse:
             begin
               // create case-else block
-              CurBlock:=TPasImplCaseOf(CurBlock).AddElse;
+              el:=TPasImplCaseElse(CreateElement(TPasImplCaseElse,'',CurBlock));
+              TPasImplCaseOf(CurBlock).ElseBranch:=TPasImplCaseElse(el);
+              CreateBlock(TPasImplCaseElse(el));
               break;
             end
           else
@@ -3225,7 +3227,6 @@ begin
         begin
           el:=TPasImplTryFinally(CreateElement(TPasImplTryFinally,'',Curblock));
           TPasImplTry(CurBlock).FinallyExcept:=TPasImplTryFinally(el);
-          CurBlock.AddElement(el);
           CurBlock:=TPasImplTryFinally(el);
         end else
           ParseExc(SParserSyntaxError);