Skip to content

Commit 319df10

Browse files
[ndarray] Fix ndarray_from_tuple reading out of _shape->items bounds (#630)
1 parent 26051d7 commit 319df10

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

code/ndarray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,10 @@ ndarray_obj_t *ndarray_new_ndarray_from_tuple(mp_obj_tuple_t *_shape, uint8_t dt
652652
// the function should work in the general n-dimensional case
653653
size_t *shape = m_new(size_t, ULAB_MAX_DIMS);
654654
for(size_t i=0; i < ULAB_MAX_DIMS; i++) {
655-
if(i < ULAB_MAX_DIMS - _shape->len) {
656-
shape[i] = 0;
655+
if(i >= _shape->len) {
656+
shape[ULAB_MAX_DIMS - i] = 0;
657657
} else {
658-
shape[i] = mp_obj_get_int(_shape->items[i]);
658+
shape[ULAB_MAX_DIMS - i] = mp_obj_get_int(_shape->items[i]);
659659
}
660660
}
661661
return ndarray_new_dense_ndarray(_shape->len, shape, dtype);

code/ulab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "user/user.h"
3434
#include "utils/utils.h"
3535

36-
#define ULAB_VERSION 6.3.1
36+
#define ULAB_VERSION 6.3.2
3737
#define xstr(s) str(s)
3838
#define str(s) #s
3939

0 commit comments

Comments
 (0)