This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] libdw: Prevent infinite recursion when processing DW_TAG_imported_unit.
- From: Petr Machata <pmachata at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Mon, 12 Jan 2015 03:15:31 +0100
- Subject: Re: [PATCH] libdw: Prevent infinite recursion when processing DW_TAG_imported_unit.
Mark Wielaard <mjw@redhat.com> writes:
> + /* Checks the given DIE hasn't been imported yet to prevent cycles. */
> + inline bool imports_contains (Dwarf_Die *die)
> + {
> + struct Dwarf_Die_Chain *import = imports;
> + while (import != NULL)
> + {
> + if (import->die.addr == die->addr)
> + return true;
> + import = import->parent;
> + }
This is equivalent but is IMHO canonical:
for (Dwarf_Die_Chain *import = imports; import != NULL;
import = import->parent)
if (import->die.addr == die->addr)
return true;
Thanks,
Petr