Skip to content

Commit

Permalink
[ndarray] Fix ndarray_from_tuple reading out of _shape->items bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNumworks committed Jun 26, 2023
1 parent 26051d7 commit 61baa23
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/ndarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,10 @@ ndarray_obj_t *ndarray_new_ndarray_from_tuple(mp_obj_tuple_t *_shape, uint8_t dt
// the function should work in the general n-dimensional case
size_t *shape = m_new(size_t, ULAB_MAX_DIMS);
for(size_t i=0; i < ULAB_MAX_DIMS; i++) {
if(i < ULAB_MAX_DIMS - _shape->len) {
shape[i] = 0;
if(i >= _shape->len) {
shape[ULAB_MAX_DIMS - i] = 0;
} else {
shape[i] = mp_obj_get_int(_shape->items[i]);
shape[ULAB_MAX_DIMS - i] = mp_obj_get_int(_shape->items[i]);
}
}
return ndarray_new_dense_ndarray(_shape->len, shape, dtype);
Expand Down

0 comments on commit 61baa23

Please sign in to comment.