aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2017-03-12 16:03:34 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2017-03-12 16:03:34 +0000
commit9f36610f9ef53017afbc50520b999882958c402c (patch)
tree48681fad678d71728cf4d1e2f4b92b96a5fad900 /lib/libc/stdio
parentab23521a4954485a56e9016dfbde6e7edff6c516 (diff)
Notes
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/open_wmemstream.c2
-rw-r--r--lib/libc/stdio/printf-pos.c2
-rw-r--r--lib/libc/stdio/ungetc.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c
index 3e8713f6b8036..d3331aabee744 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",
diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c
index b81e27a2d64b9..5b36f1aff9bd2 100644
--- a/lib/libc/stdio/printf-pos.c
+++ b/lib/libc/stdio/printf-pos.c
@@ -655,7 +655,7 @@ __grow_type_table(struct typetable *types)
return (-1);
bcopy(oldtable, newtable, oldsize * sizeof(enum typeid));
} else {
- newtable = realloc(oldtable, newsize * sizeof(enum typeid));
+ newtable = reallocarray(oldtable, newsize, sizeof(enum typeid));
if (newtable == NULL)
return (-1);
}
diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c
index 1695af772daaf..88c9da5551870 100644
--- a/lib/libc/stdio/ungetc.c
+++ b/lib/libc/stdio/ungetc.c
@@ -73,14 +73,14 @@ __submore(FILE *fp)
return (0);
}
i = fp->_ub._size;
- p = realloc(fp->_ub._base, (size_t)(i << 1));
+ p = reallocarray(fp->_ub._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;
fp->_ub._base = p;
- fp->_ub._size = i << 1;
+ fp->_ub._size = i * 2;
return (0);
}