libsel4utils: check variable before dereferencing
diff --git a/libsel4utils/src/elf.c b/libsel4utils/src/elf.c
index 18db1f3..6767d16 100644
--- a/libsel4utils/src/elf.c
+++ b/libsel4utils/src/elf.c
@@ -514,8 +514,11 @@
uintptr_t sel4utils_elf_get_vsyscall(elf_t *elf_file)
{
uintptr_t* addr = (uintptr_t*)sel4utils_elf_get_section(elf_file, "__vsyscall", NULL);
- /* Hope everything is good and just dereference it */
- return *addr;
+ if (addr) {
+ return *addr;
+ } else {
+ return 0;
+ }
}
uintptr_t sel4utils_elf_get_section(elf_t *elf_file, const char *section_name, uint64_t* section_size)