From 7e8e8745207120bbd4df0d913f758994c1e09475 Mon Sep 17 00:00:00 2001 From: Doug Hogan Date: Sat, 18 Oct 2014 03:16:20 +0000 Subject: Simple malloc() to reallocarray() conversion. ok deraadt@ --- libexec/ld.so/ldd/ldd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libexec') diff --git a/libexec/ld.so/ldd/ldd.c b/libexec/ld.so/ldd/ldd.c index a682ea01e3b..f68237160b5 100644 --- a/libexec/ld.so/ldd/ldd.c +++ b/libexec/ld.so/ldd/ldd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldd.c,v 1.16 2013/07/14 14:36:41 jca Exp $ */ +/* $OpenBSD: ldd.c,v 1.17 2014/10/18 03:16:19 doug Exp $ */ /* * Copyright (c) 2001 Artur Grabowski * All rights reserved. @@ -116,9 +116,9 @@ doit(char *name) return 1; } + if ((phdr = reallocarray(NULL, ehdr.e_phnum, sizeof(Elf_Phdr))) == NULL) + err(1, "reallocarray"); size = ehdr.e_phnum * sizeof(Elf_Phdr); - if ((phdr = malloc(size)) == NULL) - err(1, "malloc"); if (pread(fd, phdr, size, ehdr.e_phoff) != size) { warn("read(%s)", name); -- cgit v1.2.3