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] [commit] Fix for "dangling" access


Greetings,

I've just committed and pushed the patch below as obvious.

The symptoms of the bug were really bizzare:
first 'print *this' produced an exception with clearly bogus type
name, but second 'print *this' worked fine.

--
Paul pluzhnikov

2008-11-07  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* python/python-type.c (typy_lookup_type): Fix "dangling" access.
	
diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c
index 77bb489..9e5e2c3 100644
--- a/gdb/python/python-type.c
+++ b/gdb/python/python-type.c
@@ -134,17 +134,22 @@ typy_lookup_type (struct demangle_component *demangled,
 {
   struct type *type;
   char *type_name;
+  enum demangle_component_type demangled_type;
 
-  if (demangled->type == DEMANGLE_COMPONENT_POINTER
-      || demangled->type == DEMANGLE_COMPONENT_REFERENCE
-      || demangled->type == DEMANGLE_COMPONENT_CONST
-      || demangled->type == DEMANGLE_COMPONENT_VOLATILE)
+  /* Save the type: typy_lookup_type() may (indirectly) overwrite
+     memory pointed by demanged.  */
+  demangled_type = demangled->type;
+
+  if (demangled_type == DEMANGLE_COMPONENT_POINTER
+      || demangled_type == DEMANGLE_COMPONENT_REFERENCE
+      || demangled_type == DEMANGLE_COMPONENT_CONST
+      || demangled_type == DEMANGLE_COMPONENT_VOLATILE)
     {
       type = typy_lookup_type (demangled->u.s_binary.left, block);
       if (! type)
        return NULL;
 
-      switch (demangled->type)
+      switch (demangled_type)
        {
        case DEMANGLE_COMPONENT_REFERENCE:
          return lookup_reference_type (type);


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