summaryrefslogtreecommitdiff
path: root/libdw/dwarf_getscopes.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdw/dwarf_getscopes.c')
-rw-r--r--libdw/dwarf_getscopes.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libdw/dwarf_getscopes.c b/libdw/dwarf_getscopes.c
index 833f1ac5..ce073b13 100644
--- a/libdw/dwarf_getscopes.c
+++ b/libdw/dwarf_getscopes.c
@@ -101,7 +101,7 @@ origin_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg)
Dwarf_Die *scopes = realloc (a->scopes, nscopes * sizeof scopes[0]);
if (scopes == NULL)
{
- free (a->scopes);
+ /* a->scopes will be freed by dwarf_getscopes on error. */
__libdw_seterrno (DWARF_E_NOMEM);
return -1;
}
@@ -200,6 +200,8 @@ dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc, Dwarf_Die **scopes)
if (result > 0)
*scopes = a.scopes;
+ else if (result < 0)
+ free (a.scopes);
return result;
}