aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-31 17:45:32 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-03 14:41:31 -0700
commit9527dd74529886cd3a6fd8f7dde9625904fe1edd (patch)
tree3f38f91fd91854498ddf05b8e4ca61cfd1b85f0f
parentbeb08e214984a234c82d3a2fd7e984dffdf2f5dc (diff)
fix cleanup code to not happen in main module
-rw-r--r--src/runtime.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 9104c55d..5c7659b5 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -404,18 +404,20 @@ var Runtime = {
});
}
- var newLength = table.length;
- jsModule.cleanups.push(function() {
- if (table.length === newLength) {
- table.length = from; // nothing added since, just shrink
- } else {
- // something was added above us, clear and leak the span
- for (var i = 0; i < num; i++) {
- table[from + i] = null;
+ if (jsModule.cleanups) {
+ var newLength = table.length;
+ jsModule.cleanups.push(function() {
+ if (table.length === newLength) {
+ table.length = from; // nothing added since, just shrink
+ } else {
+ // something was added above us, clear and leak the span
+ for (var i = 0; i < num; i++) {
+ table[from + i] = null;
+ }
}
- }
- while (table.length > 0 && table[table.length-1] === null) table.pop();
- });
+ while (table.length > 0 && table[table.length-1] === null) table.pop();
+ });
+ }
// patch js module dynCall_* to use functionTable
sigs.forEach(function(sig) {