* Re: [PATCH] libdw: Don't leak duplicate FDEs.
@ 2016-01-02 20:14 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2016-01-02 20:14 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 246 bytes --]
On Wed, Dec 02, 2015 at 05:09:24PM +0100, Mark Wielaard wrote:
> 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.
Pushed to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] libdw: Don't leak duplicate FDEs.
@ 2015-12-02 16:09 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2015-12-02 16:09 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1547 bytes --]
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>
---
libdw/ChangeLog | 4 ++++
libdw/fde.c | 11 ++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 10df13b..f8b4793 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2015-12-02 Mark Wielaard <mjw@redhat.com>
+
+ * fde.c (intern_fde): Don't leak duplicate FDEs.
+
2015-12-01 Mark Wielaard <mjw@redhat.com>
* fde.c (intern_fde): Don't intern an fde that doesn't cover a
diff --git a/libdw/fde.c b/libdw/fde.c
index 2a59d3e..f5f6fbe 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;
}
--
2.5.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-02 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-02 20:14 [PATCH] libdw: Don't leak duplicate FDEs Mark Wielaard
-- strict thread matches above, loose matches on Subject: below --
2015-12-02 16:09 Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).