diff options
author | Lars Buitinck <larsmans@gmail.com> | 2015-06-14 20:45:43 +0200 |
---|---|---|
committer | Lars Buitinck <larsmans@gmail.com> | 2015-06-14 21:07:09 +0200 |
commit | 7f0900f0f08f9218428ce2d0dd0908af0f9b8cc9 (patch) | |
tree | 318bf077f9e311319a16ccf784997e7bb0d0ed6b | |
parent | 524d6f9672eb737b40b4981bc9977ad71a3f19df (diff) | |
download | numpy-7f0900f0f08f9218428ce2d0dd0908af0f9b8cc9.tar.gz |
BUG: erroneous use of sprintf
Output argument was a char ** instead of a char *.
Also changed to use snprintf for safety; if the error message is
ever changed, the magic number 174 (!?) is likely to go stale,
causing buffer overruns.
-rw-r--r-- | numpy/core/src/multiarray/mapping.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index 604f5390f..a703f3d84 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -772,8 +772,8 @@ prepare_index(PyArrayObject *self, PyObject *index, if (indices[i].value != PyArray_DIM(self, used_ndim)) { static PyObject *warning; - char *err_msg[174]; - sprintf(err_msg, + char err_msg[174]; + PyOS_snprintf(err_msg, sizeof(err_msg), "boolean index did not match indexed array along " "dimension %d; dimension is %" NPY_INTP_FMT " but corresponding boolean dimension is %" NPY_INTP_FMT, |