This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils 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]

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

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