[ndarray] Fix ndarray_from_tuple reading out of _shape->items bounds (#630)

This commit is contained in:
FelixNumworks 2023-06-26 22:21:50 +02:00 committed by GitHub
parent 26051d70d2
commit 319df10cfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -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);

View file

@ -33,7 +33,7 @@
#include "user/user.h"
#include "utils/utils.h"
#define ULAB_VERSION 6.3.1
#define ULAB_VERSION 6.3.2
#define xstr(s) str(s)
#define str(s) #s