diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2011-04-24 11:51:51 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-04-24 11:51:51 -0600 |
commit | 9752349d0e6f21298b99d2175e9a7846c0589c91 (patch) | |
tree | 18ea3f4aa3211c845a9556176cf3f430a0121fdf | |
parent | d8de71d14ce7ac08a51d06623437f1df35035a5e (diff) | |
download | numpy-9752349d0e6f21298b99d2175e9a7846c0589c91.tar.gz |
DOC: Add note about the danger of integer overflow when computing array
sizes by multiplying the dimensions together.
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index a026ecb4d..bbbf91f36 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -978,6 +978,12 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, return NULL; } + /* + * Care needs to be taken to avoid integer overflow when + * multiplying the dimensions together to get the total size of the + * array. Hence before each multiplication we first check that the + * product will not exceed the maximum allowable size. + */ if (dim > largest) { PyErr_SetString(PyExc_ValueError, "array is too big."); |