summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPino Toscano <[email protected]>2015-06-27 18:33:37 +0200
committerMark Wielaard <[email protected]>2015-06-27 23:25:57 +0200
commit349d1cd1a34a7f9ee6a93aa6cf839ce0c8ceea28 (patch)
treeb6bae2189085213573c936e2faac5df45f78b14e
parentaf29f77436f827d10ec9004120426cffd3401137 (diff)
tests: dwfl-bug-fd-leak: Guard against null module addresses
Do not crash if there is no module for the given address. Signed-off-by: Pino Toscano <[email protected]>
-rw-r--r--tests/ChangeLog5
-rw-r--r--tests/dwfl-bug-fd-leak.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 34611682..3e567b34 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-27 Pino Toscano <[email protected]>
+
+ * tests/dwfl-bug-fd-leak.c (elfutils_open): Check for null results of
+ dwfl_addrmodule.
+
2015-06-26 Pino Toscano <[email protected]>
* tests/vdsosyms.c [!__linux__] (main): Mark argv as unused.
diff --git a/tests/dwfl-bug-fd-leak.c b/tests/dwfl-bug-fd-leak.c
index 170a61a7..bcbfb290 100644
--- a/tests/dwfl-bug-fd-leak.c
+++ b/tests/dwfl-bug-fd-leak.c
@@ -65,7 +65,11 @@ elfutils_open (pid_t pid, Dwarf_Addr address)
}
else
{
- Elf *elf = dwfl_module_getelf (dwfl_addrmodule (dwfl, address), &bias);
+ Dwfl_Module *module = dwfl_addrmodule (dwfl, address);
+ if (module == NULL)
+ error (2, 0, "dwfl_addrmodule: no module available for 0x%" PRIx64 "",
+ address);
+ Elf *elf = dwfl_module_getelf (module, &bias);
if (elf == NULL)
error (2, 0, "dwfl_module_getelf: %s", dwfl_errmsg (-1));
}