diff options
author | 2017-03-17 14:53:08 +0000 | |
---|---|---|
committer | 2017-03-17 14:53:08 +0000 | |
commit | 977aa0f22cea0809e6a84289ed753ba3f0b53fa7 (patch) | |
tree | edc3a3a21d8bdc826b2eb933725c61be66cc74c9 /lib/libc/stdio/fgetln.c | |
parent | Fix a couple of argument types. (diff) | |
download | wireguard-openbsd-977aa0f22cea0809e6a84289ed753ba3f0b53fa7.tar.xz wireguard-openbsd-977aa0f22cea0809e6a84289ed753ba3f0b53fa7.zip |
Use recallocarray() to avoid leaving detritus in memory when resizing
buffers. We don't bother doing this for objects containing pointers,
but focus on controllable data.
ok millert
Diffstat (limited to 'lib/libc/stdio/fgetln.c')
-rw-r--r-- | lib/libc/stdio/fgetln.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdio/fgetln.c b/lib/libc/stdio/fgetln.c index bdb0c2a5b37..903dbd60661 100644 --- a/lib/libc/stdio/fgetln.c +++ b/lib/libc/stdio/fgetln.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fgetln.c,v 1.16 2016/09/21 04:38:56 guenther Exp $ */ +/* $OpenBSD: fgetln.c,v 1.17 2017/03/17 14:53:08 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -46,7 +46,7 @@ __slbexpand(FILE *fp, size_t newsize) if (fp->_lb._size >= newsize) return (0); - if ((p = realloc(fp->_lb._base, newsize)) == NULL) + if ((p = recallocarray(fp->_lb._base, fp->_lb._size, newsize, 1)) == NULL) return (-1); fp->_lb._base = p; fp->_lb._size = newsize; |