summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2008-07-16 21:30:07 +0000
committerCharles Harris <charlesr.harris@gmail.com>2008-07-16 21:30:07 +0000
commitf90a9240436e179acc6b4428cc4cff17a06fd6ac (patch)
tree71038f052d59bd4fa1cfe64af94d8b3b82e83dfd /numpy
parent75a3b814dc8dc1df038b3afb9b9bf1b19a7d43da (diff)
downloadnumpy-f90a9240436e179acc6b4428cc4cff17a06fd6ac.tar.gz
Fix ticket #849. Thanks to Michael Abbott.
The added check for NULL descr isn't really needed here because the typenums used don't allow such returns. But knowing that requires knowledge of PyArray_DescrFromType internals and not checking makes the code fragile.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/blasdot/_dotblas.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/core/blasdot/_dotblas.c b/numpy/core/blasdot/_dotblas.c
index e5ff365e7..3ae1e2db1 100644
--- a/numpy/core/blasdot/_dotblas.c
+++ b/numpy/core/blasdot/_dotblas.c
@@ -206,10 +206,10 @@ static PyObject *
dotblas_matrixproduct(PyObject *dummy, PyObject *args)
{
PyObject *op1, *op2;
- PyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;
+ PyArrayObject *ap1 = NULL, *ap2 = NULL, *ret = NULL;
int j, l, lda, ldb, ldc;
int typenum, nd;
- intp ap1stride=0;
+ intp ap1stride = 0;
intp dimensions[MAX_DIMS];
intp numbytes;
static const float oneF[2] = {1.0, 0.0};
@@ -240,14 +240,19 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args)
}
dtype = PyArray_DescrFromType(typenum);
+ if (dtype == NULL) {
+ return NULL;
+ }
+ Py_INCREF(dtype);
ap1 = (PyArrayObject *)PyArray_FromAny(op1, dtype, 0, 0, ALIGNED, NULL);
if (ap1 == NULL) {
+ Py_DECREF(dtype);
return NULL;
}
- Py_INCREF(dtype);
ap2 = (PyArrayObject *)PyArray_FromAny(op2, dtype, 0, 0, ALIGNED, NULL);
if (ap2 == NULL) {
- goto fail;
+ Py_DECREF(ap1);
+ return NULL;
}