summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/open_wmemstream.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-04-07 16:08:04 +0000
committerpfg <pfg@FreeBSD.org>2017-04-07 16:08:04 +0000
commitfeaeb09c7553a3cb3242f6be7b39a5f4b4d5a3e7 (patch)
tree9779b1eeb4a9a1f1c6fccb20ee1fb04a426efb9d /lib/libc/stdio/open_wmemstream.c
parent7317fc9c0522c902a4a0a67b17c5c5d25d04bff9 (diff)
downloadFreeBSD-src-feaeb09c7553a3cb3242f6be7b39a5f4b4d5a3e7.zip
FreeBSD-src-feaeb09c7553a3cb3242f6be7b39a5f4b4d5a3e7.tar.gz
MFC r315162:
libc: provide some bounds-checking through reallocarray(3). reallocarray(3) is a non portable extension that originated in OpenBSD. Given that it is already in FreeBSD's libc it is useful for the cases where reallocation involves a multiplication.
Diffstat (limited to 'lib/libc/stdio/open_wmemstream.c')
-rw-r--r--lib/libc/stdio/open_wmemstream.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c
index 3e8713f..d3331aa 100644
--- a/lib/libc/stdio/open_wmemstream.c
+++ b/lib/libc/stdio/open_wmemstream.c
@@ -63,7 +63,7 @@ wmemstream_grow(struct wmemstream *ms, fpos_t newoff)
else
newsize = newoff;
if (newsize > ms->len) {
- buf = realloc(*ms->bufp, (newsize + 1) * sizeof(wchar_t));
+ buf = reallocarray(*ms->bufp, newsize + 1, sizeof(wchar_t));
if (buf != NULL) {
#ifdef DEBUG
fprintf(stderr, "WMS: %p growing from %zd to %zd\n",
OpenPOWER on IntegriCloud