diff options
author | kpdecker <kpdecker@gmail.com> | 2013-12-31 21:18:42 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-12-31 21:18:48 -0600 |
commit | cd885bf855e914d27a511273f548ab01b5fd3b7e (patch) | |
tree | 5851ec0acd80e9bf762585c15c787c6c58446409 /lib/handlebars/compiler/javascript-compiler.js | |
parent | ddfe457abfe85b14ba4c95c3a9f434d04e02ec23 (diff) | |
download | handlebars.js-cd885bf855e914d27a511273f548ab01b5fd3b7e.zip handlebars.js-cd885bf855e914d27a511273f548ab01b5fd3b7e.tar.gz handlebars.js-cd885bf855e914d27a511273f548ab01b5fd3b7e.tar.bz2 |
Add stack handling sanity checks
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 7ad400c..526ddc1 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -1,4 +1,5 @@ import { COMPILER_REVISION, REVISION_CHANGES, log } from "../base"; +import Exception from "../exception"; function Literal(value) { this.value = value; @@ -104,6 +105,10 @@ JavaScriptCompiler.prototype = { // Flush any trailing content that might be pending. this.pushSource(''); + if (this.stackSlot || this.inlineStack.length || this.compileStack.length) { + throw new Exception('Compile completed with content left on stack'); + } + return this.createFunctionContext(asObject); }, @@ -771,6 +776,9 @@ JavaScriptCompiler.prototype = { return item.value; } else { if (!inline) { + if (!this.stackSlot) { + throw new Exception('Invalid stack pop'); + } this.stackSlot--; } return item; |