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 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 ();
 


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