diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-16 17:46:05 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-16 17:46:05 -0800 |
commit | ef3d0541e91af4b7279bd8e30b112b1a3a108f9e (patch) | |
tree | 0a47cfd57be19b093e06f92e7f15186f9dbad9c5 /src/runtime.js | |
parent | 086526150c8dc53800a63af9571c62410a161cc6 (diff) |
fix bug with accessing memory beyond TOTAL_MEMORY through sbrk
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/runtime.js b/src/runtime.js index 0b36f967..e1a6db39 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -10,7 +10,7 @@ var RuntimeGenerator = { alloc: function(size, type, init) { var ret = type + 'TOP'; if (ASSERTIONS) { - ret += '; assert(' + size + ' > 0, "Trying to allocate 0")'; + ret += '; assert(' + size + ' != 0, "Trying to allocate 0")'; } if (init) { ret += '; _memset(' + type + 'TOP, 0, ' + size + ')'; @@ -54,11 +54,10 @@ var RuntimeGenerator = { return ret += 'STACKTOP = __stackBase__'; }, - // An allocation that cannot be free'd + // An allocation that cannot normally be free'd (except through sbrk, which once + // called, takes control of STATICTOP) staticAlloc: function(size) { - var ret = ''; - if (USE_TYPED_ARRAYS) ret += 'LAST_STATICTOP = STATICTOP;' - ret += RuntimeGenerator.alloc(size, 'STATIC', INIT_HEAP); + var ret = RuntimeGenerator.alloc(size, 'STATIC', INIT_HEAP); if (USE_TYPED_ARRAYS) ret += '; if (STATICTOP >= TOTAL_MEMORY) enlargeMemory();' return ret; }, |