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]

[PATCH 27/28] rearrange for some clarity in valpy_get_dynamic_type


The checker noticed some funny code in valpy_get_dynamic_type.  This
simplifies the code a little and also changes an incref to an xincref;
the current code could crash if type_to_type_object failed.

	* python/py-value.c (valpy_get_dynamic_type): Simplify
	dynamic_type assignment.  Use Py_XINCREF.
---
 gdb/python/py-value.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index e4f4263..df4bf77 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -334,18 +334,11 @@ valpy_get_dynamic_type (PyObject *self, void *closure)
   GDB_PY_HANDLE_EXCEPTION (except);
 
   if (type == NULL)
-    {
-      /* Ensure that the TYPE field is ready.  */
-      if (!valpy_get_type (self, NULL))
-	return NULL;
-      /* We don't need to incref here, because valpy_get_type already
-	 did it for us.  */
-      obj->dynamic_type = obj->type;
-    }
+    obj->dynamic_type = valpy_get_type (self, NULL);
   else
     obj->dynamic_type = type_to_type_object (type);
 
-  Py_INCREF (obj->dynamic_type);
+  Py_XINCREF (obj->dynamic_type);
   return obj->dynamic_type;
 }
 
-- 
1.8.1.4



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