restore template object state on exception, free lexer/parser resources

This commit is contained in:
Uwe Tews
2015-08-06 19:40:37 +02:00
parent e402e2f893
commit 5d1ba7ca9c

View File

@@ -415,7 +415,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
Smarty_Internal_Debug::end_compile($this->template); Smarty_Internal_Debug::end_compile($this->template);
} }
// free memory // free memory
unset($this->parser->lex, $this->parser->root_buffer, $this->parser->current_buffer, $this->parser); $this->parser = null;
} }
// restore source // restore source
$this->template->source = $this->savedSource; $this->template->source = $this->savedSource;
@@ -452,6 +452,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
} }
} }
catch (Exception $e) { catch (Exception $e) {
$this->_tag_stack = array();
$this->_tag_objects = array();
// restore source // restore source
$this->template->source = $this->savedSource; $this->template->source = $this->savedSource;
$this->savedSource = null; $this->savedSource = null;
@@ -459,8 +461,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
// free memory // free memory
$this->parent_compiler = null; $this->parent_compiler = null;
$this->template = null; $this->template = null;
$this->_tag_stack = array();
$this->_tag_objects = array();
$this->parser = null; $this->parser = null;
throw $e; throw $e;
} }