This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] fix crash in Parameters
- From: Tom Tromey <tromey at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Tue, 02 Dec 2008 09:13:29 -0700
- Subject: [python] fix crash in Parameters
- Reply-to: Tom Tromey <tromey at redhat dot com>
If you tried to delete a Parameter's value attribute, gdb would crash.
This isn't valid, so this patch turns it into an exception.
Tom
2008-12-02 Tom Tromey <tromey@redhat.com>
* python/python-param.c (set_attr): Don't let user delete the
value.
diff --git a/gdb/python/python-param.c b/gdb/python/python-param.c
index aad8932..dc1aec3 100644
--- a/gdb/python/python-param.c
+++ b/gdb/python/python-param.c
@@ -244,7 +244,15 @@ set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
{
if (PyString_Check (attr_name)
&& ! strcmp (PyString_AsString (attr_name), "value"))
- return set_parameter_value ((parmpy_object *) obj, val);
+ {
+ if (!val)
+ {
+ PyErr_SetString (PyExc_RuntimeError,
+ "cannot delete a parameter's value");
+ return -1;
+ }
+ return set_parameter_value ((parmpy_object *) obj, val);
+ }
return PyObject_GenericSetAttr (obj, attr_name, val);
}