summaryrefslogtreecommitdiff
path: root/numpy/core/src/ufuncobject.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-03-28 05:03:50 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-03-28 05:03:50 +0000
commitb8f582defd3c10e5e38018970bb52ab693951dfa (patch)
treeaec333c41746da37166e4717c91567d7c9ca1300 /numpy/core/src/ufuncobject.c
parentb30372185f472b29d4b2ac3f703359b9376a8b60 (diff)
downloadnumpy-b8f582defd3c10e5e38018970bb52ab693951dfa.tar.gz
Fix some Py_INCREF's to Py_XINCREF to avoid segfault when NULL is stored.
Diffstat (limited to 'numpy/core/src/ufuncobject.c')
-rw-r--r--numpy/core/src/ufuncobject.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/numpy/core/src/ufuncobject.c b/numpy/core/src/ufuncobject.c
index 3b3b0429b..0123b6f5e 100644
--- a/numpy/core/src/ufuncobject.c
+++ b/numpy/core/src/ufuncobject.c
@@ -2425,8 +2425,9 @@ PyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *out,
NULL);
loop->cast(loop->buffer, loop->castbuf,
1, NULL, NULL);
- if (loop->obj)
- Py_INCREF(*((PyObject **)loop->castbuf));
+ if (loop->obj) {
+ Py_XINCREF(*((PyObject **)loop->castbuf));
+ }
memcpy(loop->bufptr[0], loop->castbuf,
loop->outsize);
}
@@ -2570,8 +2571,9 @@ PyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *out,
NULL);
loop->cast(loop->buffer, loop->castbuf,
1, NULL, NULL);
- if (loop->obj)
- Py_INCREF(*((PyObject **)loop->castbuf));
+ if (loop->obj) {
+ Py_XINCREF(*((PyObject **)loop->castbuf));
+ }
memcpy(loop->bufptr[0], loop->castbuf,
loop->outsize);
}
@@ -2693,8 +2695,9 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind,
for (i=0; i<nn; i++) {
loop->bufptr[1] = loop->it->dataptr + \
(*ptr)*loop->instrides;
- if (loop->obj)
- Py_INCREF(*((PyObject **)loop->bufptr[1]));
+ if (loop->obj) {
+ Py_XINCREF(*((PyObject **)loop->bufptr[1]));
+ }
memcpy(loop->bufptr[0], loop->bufptr[1],
loop->outsize);
mm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \
@@ -2723,8 +2726,9 @@ PyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind,
while(loop->index < loop->size) {
ptr = (intp *)ind->data;
for (i=0; i<nn; i++) {
- if (loop->obj)
- Py_INCREF(*((PyObject **)loop->idptr));
+ if (loop->obj) {
+ Py_XINCREF(*((PyObject **)loop->idptr));
+ }
memcpy(loop->bufptr[0], loop->idptr,
loop->outsize);
n = 0;