This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: fix latent leak in cmdpy_function


I'm checking this in.

PyErr_Fetch gives the caller a reference to each returned object.
This patch changes cmdpy_function to decref the objects in the branch
where PyErr_Restore is not called.

Built and regtested on x86-64 (compile farm).

Tom

2010-10-19  Tom Tromey  <tromey@redhat.com>

	* python/py-cmd.c (cmdpy_function): Unreference exception state.

Index: python/py-cmd.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-cmd.c,v
retrieving revision 1.8
diff -u -r1.8 py-cmd.c
--- python/py-cmd.c	13 Oct 2010 13:24:39 -0000	1.8
+++ python/py-cmd.c	19 Oct 2010 20:09:01 -0000
@@ -192,7 +192,12 @@
 	    error (_("Error occurred in Python command."));
 	}
       else
-	error ("%s", msg);
+	{
+	  Py_XDECREF (ptype);
+	  Py_XDECREF (pvalue);
+	  Py_XDECREF (ptraceback);
+	  error ("%s", msg);
+	}
     }
 
   Py_DECREF (result);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]