Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1690: fix(c-api) `wasm_limits_t` contains `Pages`, not `Bytes` + sentinel value r=Hywan a=Hywan When building a `wasm_memorytype_t` with `wasm_memorytype_new`, we pass a `wasm_limits_t`, where `min` and `max` represent `Pages`. This semantics is set by `wasm_memorytype_new` itself where `min` and `max` from `wasm_limits_t` are used to compute `Pages`, which are then passed to `MemoryType`. Then, in `wasm_memorytype_limits`, we expect to get the same `wasm_limits_t` given to `wasm_memorytype_new`. But it's not! The same `MemoryType` is read, good. The `minimum` and `maximum` fields are `Pages`, good. Then, we compute the `min` and `max` values for the resulting `wasm_limits_t`, which receive `Page.bytes().0`, not good! We don't want the number of bytes, but the number of pages. This patch fixes that. Edit: This patch also fixes the max limit sentinel value. In `wasm.h`, it is defined by `wasm_limits_max_default` (`0xffffffff`). In our code, it is correctly used in `wasm_memorytype_new`, but not in `wasm_memorytype_limits`. A new constant has been introduced: `LIMITS_MAX_SENTINEL`. Not super happy with this name though. Co-authored-by: Ivan Enderlin <[email protected]>
- Loading branch information