Skip to content

Commit 46b120c

Browse files
author
Rue Yokaze
committed
add dimensionality check for index operators
1 parent b5c54a4 commit 46b120c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

python_multi_array.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ namespace python_multi_array
203203
}
204204
}
205205
// assume idx to be a list or a tuple
206+
if (N != python::len(idx))
207+
{
208+
throw std::invalid_argument("idx");
209+
}
206210
size_t s[N];
207211
for (size_t i = 0; i < N; ++i)
208212
{
@@ -230,6 +234,10 @@ namespace python_multi_array
230234
}
231235
}
232236
// assume idx to be a list or a tuple
237+
if (N != python::len(idx))
238+
{
239+
throw std::invalid_argument("idx");
240+
}
233241
size_t s[N];
234242
for (size_t i = 0; i < N; ++i)
235243
{

0 commit comments

Comments
 (0)