summaryrefslogtreecommitdiff
path: root/libdw/fde.c
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2015-12-02 17:07:40 +0100
committerMark Wielaard <mjw@redhat.com>2016-01-02 20:37:45 +0100
commit8bbfc552a062e47e307a897e49f2a4a25ba6291e (patch)
treeab1a378ae1ca9444ae4721ec2f008105ff700bd9 /libdw/fde.c
parent70cd907e38757283f3696465771f723a342cc3d1 (diff)
downloadelfutils-8bbfc552a062e47e307a897e49f2a4a25ba6291e.tar.gz
libdw: Don't leak duplicate FDEs.
Although it isn't supposed to happen there could be FDEs that cover the same address range. Don't leak such FDEs and use an existing FDE for consistency. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libdw/fde.c')
-rw-r--r--libdw/fde.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libdw/fde.c b/libdw/fde.c
index 2a59d3e1..f5f6fbe1 100644
--- a/libdw/fde.c
+++ b/libdw/fde.c
@@ -119,12 +119,21 @@ intern_fde (Dwarf_CFI *cache, const Dwarf_FDE *entry)
fde->instructions += cie->fde_augmentation_data_size;
/* Add the new entry to the search tree. */
- if (tsearch (fde, &cache->fde_tree, &compare_fde) == NULL)
+ struct dwarf_fde **tres = tsearch (fde, &cache->fde_tree, &compare_fde);
+ if (tres == NULL)
{
free (fde);
__libdw_seterrno (DWARF_E_NOMEM);
return NULL;
}
+ else if (*tres != fde)
+ {
+ /* There is already an FDE in the cache that covers the same
+ address range. That is odd. Ignore this FDE. And just use
+ the one in the cache for consistency. */
+ free (fde);
+ return *tres;
+ }
return fde;
}