diff options
Diffstat (limited to 'js/src/jit-test/tests/ctypes/size-overflow-struct.js')
-rw-r--r-- | js/src/jit-test/tests/ctypes/size-overflow-struct.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ctypes/size-overflow-struct.js b/js/src/jit-test/tests/ctypes/size-overflow-struct.js new file mode 100644 index 000000000..a40f925a7 --- /dev/null +++ b/js/src/jit-test/tests/ctypes/size-overflow-struct.js @@ -0,0 +1,24 @@ +load(libdir + 'asserts.js'); + +function test() { + if (getBuildConfiguration()["pointer-byte-size"] == 4) { + let big_array = ctypes.int32_t.array(0xfffffff); + assertRangeErrorMessage(() => { ctypes.StructType("x", [{a: big_array}, + {b: big_array}, + {c: big_array}, + {d: big_array}, + {e: big_array}]); }, + "struct size does not fit in size_t"); + } else if (getBuildConfiguration()["pointer-byte-size"] == 8) { + let big_array = ctypes.int32_t.array(0xfffffffffffffff); + assertRangeErrorMessage(() => { ctypes.StructType("x", [{a: big_array}, + {b: big_array}, + {c: big_array}, + {d: big_array}, + {e: big_array}]); }, + "struct size does not fit in size_t"); + } +} + +if (typeof ctypes === "object") + test(); |