Skip to content

Commit ba2765f

Browse files
committed
runtime: add trivial mmap failure check
1 parent f6c0b18 commit ba2765f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/runtime/runtime.c

+5
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ bool appimage_get_elf_section_offset_and_length(const char* fname, const char* s
321321
data = mmap(NULL, map_size, PROT_READ, MAP_SHARED, fd, 0);
322322
close(fd);
323323

324+
if (data == MAP_FAILED) {
325+
fprintf(stderr, "Failed to mmap file %s: %s\n", fname, strerror(errno));
326+
return false;
327+
}
328+
324329
// this trick works as both 32 and 64 bit ELF files start with the e_ident[EI_NINDENT] section
325330
unsigned char class = data[EI_CLASS];
326331

0 commit comments

Comments
 (0)