From 5d4187339f9f2f338d540adbdfd174aa9f1e92ab Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Fri, 18 Apr 2025 22:42:17 +0100 Subject: gdb/python: fix memory leak of gdb.Color objects I noticed that this commit: commit 6447969d0ac774b6dec0f95a0d3d27c27d158690 Date: Sat Oct 5 22:27:44 2024 +0300 Add an option with a color type. has an unnecessary `Py_INCREF (self);` in gdb.Color.__init__. This means that the reference count on all gdb.Color objects (that pass through __init__) will be +1 from where they should normally be, and this will stop the gdb.Color objects from being deallocated. Fix by removing the Py_INCREF call. Add a test which exposes the memory leak. Approved-By: Tom Tromey --- gdb/python/py-color.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gdb/python') diff --git a/gdb/python/py-color.c b/gdb/python/py-color.c index 91ad7ae..28f4142 100644 --- a/gdb/python/py-color.c +++ b/gdb/python/py-color.c @@ -256,7 +256,6 @@ colorpy_init (PyObject *self, PyObject *args, PyObject *kwds) return gdbpy_handle_gdb_exception (-1, except); } - Py_INCREF (self); return 0; } -- cgit v1.1