Add stack handling sanity checks
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user