summaryrefslogtreecommitdiff
path: root/distrib/common/elfrd_size.c
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/common/elfrd_size.c')
-rw-r--r--distrib/common/elfrd_size.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/distrib/common/elfrd_size.c b/distrib/common/elfrd_size.c
index 60bb1807585..d53442b69ff 100644
--- a/distrib/common/elfrd_size.c
+++ b/distrib/common/elfrd_size.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: elfrd_size.c,v 1.8 2017/12/03 19:32:19 tb Exp $ */
+
#include <sys/types.h>
#include <sys/file.h>
#include <sys/mman.h>
@@ -52,8 +54,10 @@ ELFNAME(locate_image)(int fd, struct elfhdr *ghead, char *file,
}
phsize = head.e_phnum * sizeof(Elf_Phdr);
- ph = malloc(phsize);
-
+ if ((ph = malloc(phsize)) == NULL) {
+ perror("malloc");
+ exit(1);
+ }
lseek(fd, head.e_phoff, SEEK_SET);