diff --git a/src/library.js b/src/library.js index 20a5ed468ea4b..a33161c9ead06 100644 --- a/src/library.js +++ b/src/library.js @@ -186,7 +186,7 @@ addToLibrary({ // it. Returns 1 on success, 0 on error. $growMemory: (size) => { var b = wasmMemory.buffer; - var pages = (size - b.byteLength + {{{ WASM_PAGE_SIZE - 1 }}}) / {{{ WASM_PAGE_SIZE }}}; + var pages = ((size - b.byteLength + {{{ WASM_PAGE_SIZE - 1 }}}) / {{{ WASM_PAGE_SIZE }}}) | 0; #if RUNTIME_DEBUG dbg(`growMemory: ${size} (+${size - b.byteLength} bytes / ${pages} pages)`); #endif @@ -195,7 +195,7 @@ addToLibrary({ #endif try { // round size grow request up to wasm page size (fixed 64KB per spec) - wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size + wasmMemory.grow({{{ toIndexType('pages') }}}); // .grow() takes a delta compared to the previous size updateMemoryViews(); #if MEMORYPROFILER if (typeof emscriptenMemoryProfiler != 'undefined') {