This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] [commit] Fix for "dangling" access
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: archer at sourceware dot org
- Cc: ppluzhnikov at google dot com
- Date: Fri, 7 Nov 2008 16:46:20 -0800 (PST)
- Subject: [python] [commit] Fix for "dangling" access
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1226105184; bh=9hzYEwzzRqvr2zhAFGj2qZf0++s=;h=DomainKey-Signature:To:Cc:Subject:Message-Id:Date:From; b=pIlwf4CJ8vtp7H4Vb62V4l5yBzw4MtmZjpDSapl1z3V75cyO8BXZYfn5I9KQqR/M2JLRY4kafFGBw0ncf+O0UA==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=to:cc:subject:message-id:date:from;b=OVi2nxyJjrpjAv49i6/aEgC5hL5xWspDiezSKuaa/xc/YbVp9VOf2Tn0JN8gmE0TewV4K8/vVZgz1rrWqTh1Fw==
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);