Skip to content

Commit

Permalink
Fix bigarray 32bit integer overflow of offset in C imp. (#11118)
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 8311a40)
  • Loading branch information
Nevor authored and xavierleroy committed Mar 16, 2022
1 parent 81eae9c commit adb1d64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -702,6 +702,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
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion runtime/bigarray.c
Expand Up @@ -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;
Expand Down

0 comments on commit adb1d64

Please sign in to comment.