[Numpy-svn] r5440 - trunk/numpy/core/blasdot

numpy-svn@scip... numpy-svn@scip...
Wed Jul 16 16:30:09 CDT 2008


Author: charris
Date: 2008-07-16 16:30:07 -0500 (Wed, 16 Jul 2008)
New Revision: 5440

Modified:
   trunk/numpy/core/blasdot/_dotblas.c
Log:
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.


Modified: trunk/numpy/core/blasdot/_dotblas.c
===================================================================
--- trunk/numpy/core/blasdot/_dotblas.c	2008-07-16 21:07:48 UTC (rev 5439)
+++ trunk/numpy/core/blasdot/_dotblas.c	2008-07-16 21:30:07 UTC (rev 5440)
@@ -206,10 +206,10 @@
 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 @@
     }
 
     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;
     }
 
 



More information about the Numpy-svn mailing list