+2015-04-21 Mark Wielaard <mjw@redhat.com>
+
+ * dwarf_getmacros.c (read_macros): Allocate attributes dynamically
+ when there are more than 8.
+
2015-04-01 Petr Machata <pmachata@redhat.com>
* libdwP.h (DWARF_E_NOT_CUDIE): New enumerator.
.endp = (void *) endp,
};
- Dwarf_Attribute attributes[proto->nforms];
+ Dwarf_Attribute *attributes;
+ Dwarf_Attribute *attributesp = NULL;
+ Dwarf_Attribute nattributes[8];
+ if (unlikely (proto->nforms > 8))
+ {
+ attributesp = malloc (sizeof (Dwarf_Attribute) * proto->nforms);
+ if (attributesp == NULL)
+ {
+ __libdw_seterrno (DWARF_E_NOMEM);
+ return -1;
+ }
+ attributes = attributesp;
+ }
+ else
+ attributes = &nattributes[0];
+
for (Dwarf_Word i = 0; i < proto->nforms; ++i)
{
/* We pretend this is a DW_AT_GNU_macros attribute so that
attributes[i].cu = &fake_cu;
size_t len = __libdw_form_val_len (&fake_cu, proto->forms[i], readp);
- if (len == (size_t) -1)
- return -1;
+ if (unlikely (len == (size_t) -1))
+ {
+ free (attributesp);
+ return -1;
+ }
readp += len;
}
.attributes = attributes,
};
- if (callback (¯o, arg) != DWARF_CB_OK)
+ int res = callback (¯o, arg);
+ if (unlikely (attributesp != NULL))
+ free (attributesp);
+
+ if (res != DWARF_CB_OK)
return readp - startp;
}