summaryrefslogtreecommitdiff
path: root/sys/arch/aviion
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2014-05-31 21:04:35 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2014-05-31 21:04:35 +0000
commita1bc025631b7001bc3928aa2c4b0f4f8e79293bd (patch)
tree5c292b3cd6bf41f94c51c7f94f6b00af1b525f0e /sys/arch/aviion
parent7b12e6ac3571f1b955542dc8bb09685052ca8bf8 (diff)
Use calloc to make sure the correct size is zeroed; Benjamin Baier
Diffstat (limited to 'sys/arch/aviion')
-rw-r--r--sys/arch/aviion/stand/a2coff/a2coff.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/arch/aviion/stand/a2coff/a2coff.c b/sys/arch/aviion/stand/a2coff/a2coff.c
index 96758a8efc2..c1d8737a7ac 100644
--- a/sys/arch/aviion/stand/a2coff/a2coff.c
+++ b/sys/arch/aviion/stand/a2coff/a2coff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: a2coff.c,v 1.10 2014/01/19 15:39:51 miod Exp $ */
+/* $OpenBSD: a2coff.c,v 1.11 2014/05/31 21:04:34 miod Exp $ */
/*
* Copyright (c) 2006, 2013, Miodrag Vallat
*
@@ -211,11 +211,10 @@ convert_elf(const char *infile, int infd, int outfd, Elf_Ehdr *ehdr)
Elf_Addr minaddr, maxaddr;
int n, last;
- phdr = (Elf_Phdr *)malloc(ehdr->e_phnum * sizeof(Elf_Phdr));
+ phdr = calloc(ehdr->e_phnum, sizeof(Elf_Phdr));
if (phdr == NULL)
- err(1, "malloc");
+ err(1, "calloc");
- memset(phdr, 0, sizeof phdr);
for (n = 0; n < ehdr->e_phnum; n++) {
if (lseek(infd, ehdr->e_phoff + n * ehdr->e_phentsize,
SEEK_SET) == (off_t) -1)