diff options
author | Roven Gabriel <nevor@nevor.net> | 2022-03-16 16:38:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 16:38:52 +0100 |
commit | 8311a408b1101c4031be15cba9e04e9d149d4fc1 (patch) | |
tree | 53215a7e5cbfda34326f5b69d9e7c9f29fb03c98 | |
parent | cfee1a6f611650b956b6cdc7dcead99647f04de9 (diff) | |
download | ocaml-8311a408b1101c4031be15cba9e04e9d149d4fc1.tar.gz |
Fix bigarray 32bit integer overflow of offset in C imp. (#11118)
A `long` type was used instead of an `intnat` type. This is wrong for Windows 64 bits.
Co-authored-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
-rw-r--r-- | Changes | 3 | ||||
-rw-r--r-- | runtime/bigarray.c | 2 |
2 files changed, 4 insertions, 1 deletions
@@ -494,6 +494,9 @@ OCaml 4.14.0 - #11101, #11109: A recursive type constraint fails on 4.14 (Jacques Garrigue, report and review by Florian Angeletti) +- #11118: Fix integer overflow on 64-bit Windows when indexing bigarrays (which + could lead to a segmentation fault). + (Roven Gabriel, review by Nicolás Ojeda Bär and Xavier Leroy) OCaml 4.13 maintenance branch ----------------------------- diff --git a/runtime/bigarray.c b/runtime/bigarray.c index 871b81ef21..ed4ff67d21 100644 --- a/runtime/bigarray.c +++ b/runtime/bigarray.c @@ -524,7 +524,7 @@ CAMLprim value caml_ba_create(value vkind, value vlayout, value vdim) are within the bounds and return the offset of the corresponding array element in the data part of the array. */ -static long caml_ba_offset(struct caml_ba_array * b, intnat * index) +static intnat caml_ba_offset(struct caml_ba_array * b, intnat * index) { intnat offset; int i; |