[Numpy-svn] r4319 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sun Oct 28 20:07:55 CDT 2007


Author: oliphant
Date: 2007-10-28 20:07:46 -0500 (Sun, 28 Oct 2007)
New Revision: 4319

Modified:
   trunk/numpy/core/src/ufuncobject.c
Log:
Fix memory leak in seterr exposed during str(a).  Fixes #602

Modified: trunk/numpy/core/src/ufuncobject.c
===================================================================
--- trunk/numpy/core/src/ufuncobject.c	2007-10-28 15:48:59 UTC (rev 4318)
+++ trunk/numpy/core/src/ufuncobject.c	2007-10-29 01:07:46 UTC (rev 4319)
@@ -3197,7 +3197,7 @@
 static int
 ufunc_update_use_defaults(void)
 {
-    PyObject *errobj;
+    PyObject *errobj=NULL;
     int errmask, bufsize;
     int res;
 
@@ -3206,7 +3206,7 @@
                               &errobj);
     PyUFunc_NUM_NODEFAULTS -= 1;
 
-    if (res < 0) return -1;
+    if (res < 0) {Py_XDECREF(errobj); return -1;}
 
     if ((errmask != UFUNC_ERR_DEFAULT) ||           \
         (bufsize != PyArray_BUFSIZE) ||             \
@@ -3216,6 +3216,7 @@
     else if (PyUFunc_NUM_NODEFAULTS > 0) {
         PyUFunc_NUM_NODEFAULTS -= 1;
     }
+    Py_XDECREF(errobj);
     return 0;
 }
 #endif



More information about the Numpy-svn mailing list