aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2025-04-18 22:42:17 +0100
committerAndrew Burgess <aburgess@redhat.com>2025-04-22 17:21:59 +0100
commit5d4187339f9f2f338d540adbdfd174aa9f1e92ab (patch)
tree1a0af6ebcf2de425cbea28755e3cfac5a4bb58a0 /gdb/python
parent93c145c2aaf3b85b7c3b7abee029da5438d6732f (diff)
downloadbinutils-5d4187339f9f2f338d540adbdfd174aa9f1e92ab.zip
binutils-5d4187339f9f2f338d540adbdfd174aa9f1e92ab.tar.gz
binutils-5d4187339f9f2f338d540adbdfd174aa9f1e92ab.tar.bz2
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 <tom@tromey.com>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-color.c1
1 files changed, 0 insertions, 1 deletions
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;
}