chiark / gitweb /
fix memory leak in python wrapper on exception
authorstevenj <stevenj@alum.mit.edu>
Thu, 8 Jul 2010 19:04:36 +0000 (15:04 -0400)
committerstevenj <stevenj@alum.mit.edu>
Thu, 8 Jul 2010 19:04:36 +0000 (15:04 -0400)
darcs-hash:20100708190436-c8de0-0b50fd5776481816285a42d5b06679666377d0ea.gz

swig/nlopt-python.i

index db1967acf79dc74ffde1aa492be7080763202403..83df76f4e4c21563aef48600435b4fd323488650 100644 (file)
@@ -138,6 +138,7 @@ static double func_python(unsigned n, const double *x, double *grad, void *f)
 
   double val = HUGE_VAL;
   if (PyErr_Occurred()) {
+    Py_XDECREF(result);
     throw nlopt::forced_stop(); // just stop, don't call PyErr_Clear()
   }
   else if (result && PyFloat_Check(result)) {