[Scipy-svn] r2621 - trunk/Lib/interpolate

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Jan 27 17:00:42 CST 2007


Author: stefan
Date: 2007-01-27 16:58:32 -0600 (Sat, 27 Jan 2007)
New Revision: 2621

Modified:
   trunk/Lib/interpolate/__fitpack.h
Log:
Fix memory leak in fitpack.  Closes ticket #248.


Modified: trunk/Lib/interpolate/__fitpack.h
===================================================================
--- trunk/Lib/interpolate/__fitpack.h	2007-01-26 21:59:58 UTC (rev 2620)
+++ trunk/Lib/interpolate/__fitpack.h	2007-01-27 22:58:32 UTC (rev 2621)
@@ -210,10 +210,16 @@
   ap_c = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE);
   if (ap_tx == NULL || ap_ty == NULL || ap_c == NULL) goto fail;
   if ((iopt==0)||(nx>nxo)||(ny>nyo)) {
+    Py_XDECREF(ap_wrk);
     ap_wrk = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE);
     if (ap_wrk == NULL) goto fail;
     /*ap_iwrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_INT);*/
   }
+  if(ap_wrk->dimensions[0]<lc) {
+    Py_XDECREF(ap_wrk);
+    ap_wrk = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE);
+    if (ap_wrk == NULL) goto fail;
+  }
   memcpy(ap_tx->data,tx,nx*sizeof(double));
   memcpy(ap_ty->data,ty,ny*sizeof(double));
   memcpy(ap_c->data,c,lc*sizeof(double));



More information about the Scipy-svn mailing list