diff options
-rw-r--r-- | scripts/fuzz_shell.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/fuzz_shell.js b/scripts/fuzz_shell.js index c4c0056f0..72120cf7f 100644 --- a/scripts/fuzz_shell.js +++ b/scripts/fuzz_shell.js @@ -134,6 +134,17 @@ function logValue(x, y) { console.log('[LoggingExternalInterface logging ' + printed(x, y) + ']'); } +// Table get/set operations need a BigInt if the table has 64-bit indexes. This +// adds a proper cast as needed. +function toAddressType(table, index) { + // First, cast to unsigned. We do not support larger indexes anyhow. + index = index >>> 0; + if (typeof table.length == 'bigint') { + return BigInt(index); + } + return index; +} + // Set up the imports. var tempRet0; var imports = { @@ -156,10 +167,10 @@ var imports = { // Table operations. 'table-get': (index) => { - return exports.table.get(index >>> 0); + return exports.table.get(toAddressType(exports.table, index)); }, 'table-set': (index, value) => { - exports.table.set(index >>> 0, value); + exports.table.set(toAddressType(exports.table, index), value); }, }, // Emscripten support. |