This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: fix buglet in gdbpy_get_display_hint
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 09 Jul 2010 14:29:33 -0600
- Subject: FYI: fix buglet in gdbpy_get_display_hint
I am checking this in on the trunk and the 7.2 branch.
This fixes a bug in gdbpy_get_display_hint that was reported to Red Hat
bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=611569
The bug is that if PyObject_CallMethodObjArgs fails, we will pass
a NULL value to gdbpy_is_string, causing a crash.
The fix is to rearrange the code in the obvious way.
Tom
2010-07-09 Tom Tromey <tromey@redhat.com>
* python/py-prettyprint.c (gdbpy_get_display_hint): Don't use
'hint' if it is NULL.
Index: python/py-prettyprint.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-prettyprint.c,v
retrieving revision 1.12
diff -u -r1.12 py-prettyprint.c
--- python/py-prettyprint.c 11 Jun 2010 15:36:09 -0000 1.12
+++ python/py-prettyprint.c 9 Jul 2010 20:00:26 -0000
@@ -229,10 +229,12 @@
return NULL;
hint = PyObject_CallMethodObjArgs (printer, gdbpy_display_hint_cst, NULL);
- if (gdbpy_is_string (hint))
- result = python_string_to_host_string (hint);
if (hint)
- Py_DECREF (hint);
+ {
+ if (gdbpy_is_string (hint))
+ result = python_string_to_host_string (hint);
+ Py_DECREF (hint);
+ }
else
gdbpy_print_stack ();