diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-02-28 07:54:11 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-02-28 07:54:11 +0000 |
commit | e11ca4d8afc3e412f530ccd55657b401294387ea (patch) | |
tree | d07ed88ff27790b30451b8f4b4da385938dd4f7a /numpy/core/src/arrayobject.c | |
parent | a538c37f2a78fda5118ffa54f8b6257f11d4b5a3 (diff) | |
download | numpy-e11ca4d8afc3e412f530ccd55657b401294387ea.tar.gz |
Fix tests and segfault in set_strides.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 7530eba4a..eed01f93a 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -4325,8 +4325,8 @@ array_strides_set(PyArrayObject *self, PyObject *obj) { PyArray_Dims newstrides = {NULL, 0}; PyArrayObject *new; - intp numbytes=-1; - intp offset; + intp numbytes=0; + intp offset=0; int buf_len; char *buf; @@ -4341,15 +4341,15 @@ array_strides_set(PyArrayObject *self, PyObject *obj) goto fail; } new = self; - offset = 0; - while(PyArray_Check(new->base)) { + while(new->base && PyArray_Check(new->base)) { new = (PyArrayObject *)(new->base); } /* Get the available memory through the buffer interface on new->base or if that fails from the current new */ - if (PyObject_AsReadBuffer(new->base, (const void **)&buf, - &buf_len) >= 0) { + if (new->base && PyObject_AsReadBuffer(new->base, + (const void **)&buf, + &buf_len) >= 0) { offset = self->data - buf; numbytes = buf_len + offset; } @@ -4361,7 +4361,7 @@ array_strides_set(PyArrayObject *self, PyObject *obj) } if (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, - self->data - new->data, + offset, self->dimensions, newstrides.ptr)) { PyErr_SetString(PyExc_ValueError, "strides is not "\ "compatible with available memory"); |