diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-12-01 06:36:05 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-12-01 06:36:05 +0000 |
commit | d64ce1902e872b6a2e9d67fc497577d94f69efe3 (patch) | |
tree | c806001a8fab519cb317d6f318d99cc38abf6503 /usr.bin/grep/grep.c | |
parent | 0ef94e6e3f97eca0d5d8834bea5c2e0448af5bc2 (diff) |
use reallocarray()
Diffstat (limited to 'usr.bin/grep/grep.c')
-rw-r--r-- | usr.bin/grep/grep.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 89830da8d44..8d844564cd2 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.47 2014/11/26 18:34:51 millert Exp $ */ +/* $OpenBSD: grep.c,v 1.48 2014/12/01 06:36:04 deraadt Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -174,7 +174,7 @@ add_pattern(char *pat, size_t len) } if (patterns == pattern_sz) { pattern_sz *= 2; - pattern = grep_realloc(pattern, ++pattern_sz * sizeof(*pattern)); + pattern = grep_reallocarray(pattern, ++pattern_sz, sizeof(*pattern)); } if (len > 0 && pat[len - 1] == '\n') --len; @@ -358,7 +358,8 @@ main(int argc, char *argv[]) /* defer adding of expressions until all arguments are parsed */ if (exprs == expr_sz) { expr_sz *= 2; - expr = grep_realloc(expr, ++expr_sz * sizeof(*expr)); + expr = grep_reallocarray(expr, ++expr_sz, + sizeof(*expr)); } needpattern = 0; expr[exprs] = optarg; |