Use a new and empty cleanup list for try statements when entering a function
authorLars Knoll <lars.knoll@digia.com>
Wed, 12 Dec 2012 17:35:42 +0000 (18:35 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Wed, 12 Dec 2012 09:05:52 +0000 (10:05 +0100)
The cleanup list is local to a function definition. Otherwise inner functions
would create cleanup code for try statements in outer functions leading
to crashes.

Change-Id: I5d35893b0ea6b0692cda44d5b34b0bb3dfc93fdd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qv4codegen.cpp

index a16d8c4..a6c1f7f 100644 (file)
@@ -1613,6 +1613,8 @@ IR::Function *Codegen::defineFunction(const QString &name, AST::Node *ast,
 {
     qSwap(_mode, mode); // enter function code.
 
+    TryCleanup *tryCleanup = 0;
+
     enterEnvironment(ast);
     IR::Function *function = _module->newFunction(name);
     if (_debugger)
@@ -1665,6 +1667,7 @@ IR::Function *Codegen::defineFunction(const QString &name, AST::Node *ast,
     qSwap(_exitBlock, exitBlock);
     qSwap(_throwBlock, throwBlock);
     qSwap(_returnAddress, returnAddress);
+    qSwap(_tryCleanup, tryCleanup);
 
     for (FormalParameterList *it = formals; it; it = it->next) {
         _function->RECEIVE(it->name.toString());
@@ -1694,6 +1697,7 @@ IR::Function *Codegen::defineFunction(const QString &name, AST::Node *ast,
     qSwap(_exitBlock, exitBlock);
     qSwap(_throwBlock, throwBlock);
     qSwap(_returnAddress, returnAddress);
+    qSwap(_tryCleanup, tryCleanup);
 
     leaveEnvironment();