This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python] fix buglet in python-value.c


I'm checking this in on the python branch.
I'm also going to send it upstream shortly.

It is not ok to "return" from the inside of a TRY_CATCH.
This will cause a crash later.

Tom

2009-08-24  Tom Tromey  <tromey@redhat.com>

	* python/python-value.c (valpy_richcompare): Don't return from
	inside a TRY_CATCH.

diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index f34df79..159c118 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -697,7 +697,10 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
     {
       value_other = convert_value_from_python (other);
       if (value_other == NULL)
-	return NULL;
+	{
+	  result = -1;
+	  break;
+	}
 
       switch (op) {
         case Py_LT:
@@ -724,11 +727,16 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
 	  /* Can't happen.  */
 	  PyErr_SetString (PyExc_NotImplementedError,
 			   "Invalid operation on gdb.Value.");
-	  return NULL;
+	  result = -1;
+	  break;
       }
     }
   GDB_PY_HANDLE_EXCEPTION (except);
 
+  /* In this case, the Python exception has already been set.  */
+  if (result < 0)
+    return NULL;
+
   if (result == 1)
     Py_RETURN_TRUE;
 


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