From f47ca3113561ba3189b892a1a956ba6bd0fdb773 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Tue, 2 Jun 2020 20:38:17 +0100 Subject: [PATCH] libctf, create: fix addition of anonymous struct/union members A Solaris-era bug causes us to check the offsets of types with no names against the first such type when ctf_add_type()ing members to a struct or union. Members with no names (i.e. anonymous struct/union members) can appear as many times as you like in a struct/union, so this check should be skipped in this case. libctf/ * ctf-create.c (membcmp) Skip nameless members. --- libctf/ChangeLog | 4 ++++ libctf/ctf-create.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/libctf/ChangeLog b/libctf/ChangeLog index acff0b185a5..671df685421 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,7 @@ +2020-07-22 Nick Alcock + + * ctf-create.c (membcmp) Skip nameless members. + 2020-07-22 Nick Alcock * ctf-create.c (ctf_add_member_offset): Support names of "" diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c index 848e725ef24..5cbcfe0a702 100644 --- a/libctf/ctf-create.c +++ b/libctf/ctf-create.c @@ -1602,6 +1602,11 @@ membcmp (const char *name, ctf_id_t type _libctf_unused_, unsigned long offset, ctf_bundle_t *ctb = arg; ctf_membinfo_t ctm; + /* Don't check nameless members (e.g. anonymous structs/unions) against each + other. */ + if (name[0] == 0) + return 0; + if (ctf_member_info (ctb->ctb_file, ctb->ctb_type, name, &ctm) < 0) { ctf_dprintf ("Conflict due to member %s iteration error: %s.\n", name, -- 2.30.2