From f90a9240436e179acc6b4428cc4cff17a06fd6ac Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 16 Jul 2008 21:30:07 +0000 Subject: 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. --- numpy/core/blasdot/_dotblas.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'numpy') 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; } -- cgit v1.2.1