From: espie Date: Sun, 18 May 2014 16:36:41 +0000 (+0000) Subject: use reallocarray X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dca6acb1d1c7b84b7d82907803b7a40492d0a166;p=openbsd use reallocarray okay miod@, millert@ --- diff --git a/bin/chio/parse.y b/bin/chio/parse.y index 479e4dd7443..434e182aab0 100644 --- a/bin/chio/parse.y +++ b/bin/chio/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.16 2013/11/25 12:51:10 benno Exp $ */ +/* $OpenBSD: parse.y,v 1.17 2014/05/18 16:36:41 espie Exp $ */ /* * Copyright (c) 2006 Bob Beck @@ -113,8 +113,8 @@ changeroptsl : changeropts nl changeropts : DRIVE STRING { void *newp; - if ((newp = realloc(curchanger->drives, - (curchanger->drivecnt + 1) * + if ((newp = reallocarray(curchanger->drives, + curchanger->drivecnt + 1, sizeof(curchanger->drives))) == NULL) err(1, NULL); curchanger->drives = newp; diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c index 122e9c4038c..923e612acb4 100644 --- a/bin/ed/glbl.c +++ b/bin/ed/glbl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glbl.c,v 1.13 2012/12/04 02:40:48 deraadt Exp $ */ +/* $OpenBSD: glbl.c,v 1.14 2014/05/18 16:36:42 espie Exp $ */ /* $NetBSD: glbl.c,v 1.2 1995/03/21 09:04:41 cgd Exp $ */ /* glob.c: This file contains the global command routines for the ed line @@ -149,8 +149,8 @@ set_active_node(line_t *lp) int ti = active_size; line_t **ts; SPL1(); - if ((ts = (line_t **) realloc(active_list, - (ti += MINBUFSZ) * sizeof(line_t **))) == NULL) { + if ((ts = reallocarray(active_list, + (ti += MINBUFSZ), sizeof(line_t **))) == NULL) { perror(NULL); seterrmsg("out of memory"); SPL0(); diff --git a/bin/ed/undo.c b/bin/ed/undo.c index e827d3eb976..5686aaa3462 100644 --- a/bin/ed/undo.c +++ b/bin/ed/undo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undo.c,v 1.11 2012/12/04 02:40:48 deraadt Exp $ */ +/* $OpenBSD: undo.c,v 1.12 2014/05/18 16:36:42 espie Exp $ */ /* $NetBSD: undo.c,v 1.2 1995/03/21 09:04:52 cgd Exp $ */ /* undo.c: This file contains the undo routines for the ed line editor */ @@ -44,7 +44,7 @@ push_undo_stack(int type, int from, int to) t = ustack; if (u_p < usize || - (t = (undo_t *) realloc(ustack, (usize += USIZE) * sizeof(undo_t))) != NULL) { + (t = reallocarray(ustack, (usize += USIZE), sizeof(undo_t))) != NULL) { ustack = t; ustack[u_p].type = type; ustack[u_p].t = get_addressed_line_node(to);