diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-10-11 04:05:11 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-10-11 04:05:11 +0000 |
commit | a4176a32168cd25acdf0759623f0b9b78ba16d8d (patch) | |
tree | 21500c179887adf5c1987e50f960a898b74d2672 /lib/libc/stdio | |
parent | 8a32127894f8225b373e626e3111cacdee92e45d (diff) |
use reallocarray, and avoid this << 1 ugliness.
ok doug
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/ungetc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c index 675733aa6f7..ec98f26c22e 100644 --- a/lib/libc/stdio/ungetc.c +++ b/lib/libc/stdio/ungetc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ungetc.c,v 1.12 2009/11/09 00:18:27 kurt Exp $ */ +/* $OpenBSD: ungetc.c,v 1.13 2014/10/11 04:05:10 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -64,14 +64,14 @@ __submore(FILE *fp) return (0); } i = _UB(fp)._size; - p = realloc(_UB(fp)._base, i << 1); + p = reallocarray(_UB(fp)._base, i, 2); if (p == NULL) return (EOF); /* no overlap (hence can use memcpy) because we doubled the size */ (void)memcpy((void *)(p + i), (void *)p, (size_t)i); fp->_p = p + i; _UB(fp)._base = p; - _UB(fp)._size = i << 1; + _UB(fp)._size = i * 2; return (0); } |