From: tedu Date: Wed, 7 May 2014 14:56:57 +0000 (+0000) Subject: use reallocarray. ok guenther X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=547153d7cba6c66ed4df0f1726cb1f301fbb4993;p=openbsd use reallocarray. ok guenther --- diff --git a/bin/pax/options.c b/bin/pax/options.c index ae73f2f2d3c..85649da0ebd 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.84 2014/02/06 20:51:55 guenther Exp $ */ +/* $OpenBSD: options.c,v 1.85 2014/05/07 14:56:57 tedu Exp $ */ /* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */ /*- @@ -779,11 +779,9 @@ tar_options(int argc, char **argv) size_t n = nincfiles + 3; struct incfile *p; - p = realloc(incfiles, - sizeof(*incfiles) * n); + p = reallocarray(incfiles, n, + sizeof(*incfiles)); if (p == NULL) { - free(incfiles); - incfiles = NULL; paxwarn(0, "Unable to allocate space " "for option list"); exit(1); diff --git a/bin/pax/tables.c b/bin/pax/tables.c index 017abc5de4f..5fc78e41665 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tables.c,v 1.30 2014/01/08 06:43:34 deraadt Exp $ */ +/* $OpenBSD: tables.c,v 1.31 2014/05/07 14:56:57 tedu Exp $ */ /* $NetBSD: tables.c,v 1.4 1995/03/21 09:07:45 cgd Exp $ */ /*- @@ -1131,7 +1131,7 @@ add_dir(char *name, struct stat *psb, int frc_mode) name = rp; } if (dircnt == dirsize) { - dblk = realloc(dirp, 2 * dirsize * sizeof(DIRDATA)); + dblk = reallocarray(dirp, dirsize, 2 * sizeof(DIRDATA)); if (dblk == NULL) { paxwarn(1, "Unable to store mode and times for created" " directory: %s", name);