diff options
author | 2014-10-11 04:05:10 +0000 | |
---|---|---|
committer | 2014-10-11 04:05:10 +0000 | |
commit | 073cae533313e5b7b0d664c79da2811d4d96e1fd (patch) | |
tree | 7a0c22e9b9927178a4cc8a1dc24a1060a14b6d05 /lib/libc/stdio/ungetc.c | |
parent | Userland reallocarray() audit. (diff) | |
download | wireguard-openbsd-073cae533313e5b7b0d664c79da2811d4d96e1fd.tar.xz wireguard-openbsd-073cae533313e5b7b0d664c79da2811d4d96e1fd.zip |
use reallocarray, and avoid this << 1 ugliness.
ok doug
Diffstat (limited to 'lib/libc/stdio/ungetc.c')
-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); } |