diff options
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/open_wmemstream.c | 2 | ||||
-rw-r--r-- | lib/libc/stdio/printf-pos.c | 2 | ||||
-rw-r--r-- | lib/libc/stdio/ungetc.c | 4 |
3 files changed, 4 insertions, 4 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", diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c index 3a47649..38cf014 100644 --- a/lib/libc/stdio/printf-pos.c +++ b/lib/libc/stdio/printf-pos.c @@ -633,7 +633,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 1695af7..88c9da5 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); } |