Make sure to not crash and just return NULL (failure) if gelf_offscn
gets a NULL Elf handle like other gelf functions do.
* libelf/gelf_newphdr.c (gelf_newphdr): Check elf is not NULL.
Signed-off-by: Mark Wielaard <[email protected]>
---
libelf/gelf_offscn.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libelf/gelf_offscn.c b/libelf/gelf_offscn.c
index cf206f5beb2e..4d77bd2a4f5d 100644
--- a/libelf/gelf_offscn.c
+++ b/libelf/gelf_offscn.c
@@ -40,6 +40,9 @@
Elf_Scn *
gelf_offscn (Elf *elf, GElf_Off offset)
{
+ if (elf == NULL)
+ return NULL;
+
if (elf->class == ELFCLASS32)
{
if ((Elf32_Off) offset != offset)
--
2.56.0