FYI: fix one more python error check

Tom Tromey tromey@redhat.com
Tue Oct 12 22:35:00 GMT 2010


I am checking this in.

While reviewing Phil's breakpoint patch, I ran across a case where we
did not properly handle an error return.

I looked again at Cython, to remove this class of bugs entirely, but I
don't think we can use it, due primarily to our exception handling
system.

Built and regtested on x86-64 (compile farm).

Tom

2010-10-12  Tom Tromey  <tromey@redhat.com>

	* python/py-prettyprint.c (search_pp_list): Fix error checking.

Index: python/py-prettyprint.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-prettyprint.c,v
retrieving revision 1.13
diff -u -r1.13 py-prettyprint.c
--- python/py-prettyprint.c	9 Jul 2010 20:29:56 -0000	1.13
+++ python/py-prettyprint.c	12 Oct 2010 22:31:57 -0000
@@ -49,9 +49,20 @@
 	return NULL;
 
       /* Skip if disabled.  */
-      if (PyObject_HasAttr (function, gdbpy_enabled_cst)
-	  && ! PyObject_IsTrue (PyObject_GetAttr (function, gdbpy_enabled_cst)))
-	continue;
+      if (PyObject_HasAttr (function, gdbpy_enabled_cst))
+	{
+	  PyObject *attr = PyObject_GetAttr (function, gdbpy_enabled_cst);
+	  int cmp;
+
+	  if (!attr)
+	    return NULL;
+	  cmp = PyObject_IsTrue (attr);
+	  if (cmp == -1)
+	    return NULL;
+
+	  if (!cmp)
+	    continue;
+	}
 
       printer = PyObject_CallFunctionObjArgs (function, value, NULL);
       if (! printer)



More information about the Gdb-patches mailing list