diff options
| author | Luuk de Gram <luuk@degram.dev> | 2023-07-03 20:08:13 +0200 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2023-07-08 17:45:04 +0200 |
| commit | 836f9fceab03c7de56eba7a9c2e810206e7e8469 (patch) | |
| tree | 216e3c7486d9c2f3aae0ab14848ad1c0cf94201e /lib/std/math.zig | |
| parent | 89396ff02ba235592641fb388e3958c2c047e728 (diff) | |
| download | zig-836f9fceab03c7de56eba7a9c2e810206e7e8469.tar.gz zig-836f9fceab03c7de56eba7a9c2e810206e7e8469.zip | |
llvm: add safety-check for Wasm memcpy
When lowering the `memcpy` instruction, LLVM will lower it to WebAssembly's
`memory.copy` instruction when the bulk-memory feature is enabled. This
instruction will trap when the destination or source pointer is out-of-bounds.
By Zig's semantics, it is valid to have an invalid pointer when the length is 0.
To prevent runtimes from trapping, we add a safety-check for slices to only
lower to a memcpy instruction when the length is larger than 0.
Diffstat (limited to 'lib/std/math.zig')
0 files changed, 0 insertions, 0 deletions
