diff --git a/libc/upstream-openbsd/lib/libc/stdio/open_memstream.c b/libc/upstream-openbsd/lib/libc/stdio/open_memstream.c index 6ee5a5c27..af0169f67 100644 --- a/libc/upstream-openbsd/lib/libc/stdio/open_memstream.c +++ b/libc/upstream-openbsd/lib/libc/stdio/open_memstream.c @@ -1,4 +1,4 @@ -/* $OpenBSD: open_memstream.c,v 1.8 2019/05/02 08:30:10 yasuoka Exp $ */ +/* $OpenBSD: open_memstream.c,v 1.10 2023/07/11 12:14:16 claudio Exp $ */ /* * Copyright (c) 2011 Martin Pieuchot @@ -53,7 +53,6 @@ memstream_write(void *v, const char *b, int l) p = recallocarray(st->string, st->size, sz, 1); if (!p) return (-1); - bzero(p + st->size, sz - st->size); *st->pbuf = st->string = p; st->size = sz; } @@ -136,7 +135,6 @@ open_memstream(char **pbuf, size_t *psize) return (NULL); } - *st->string = '\0'; st->pos = 0; st->len = 0; st->pbuf = pbuf; diff --git a/libc/upstream-openbsd/lib/libc/stdio/open_wmemstream.c b/libc/upstream-openbsd/lib/libc/stdio/open_wmemstream.c index aceef3515..fca0b7138 100644 --- a/libc/upstream-openbsd/lib/libc/stdio/open_wmemstream.c +++ b/libc/upstream-openbsd/lib/libc/stdio/open_wmemstream.c @@ -1,4 +1,4 @@ -/* $OpenBSD: open_wmemstream.c,v 1.8 2015/09/12 16:23:14 guenther Exp $ */ +/* $OpenBSD: open_wmemstream.c,v 1.10 2023/07/11 12:14:16 claudio Exp $ */ /* * Copyright (c) 2011 Martin Pieuchot @@ -52,10 +52,9 @@ wmemstream_write(void *v, const char *b, int l) if (sz < end + 1) sz = end + 1; - p = reallocarray(st->string, sz, sizeof(wchar_t)); + p = recallocarray(st->string, st->size, sz, sizeof(wchar_t)); if (!p) return (-1); - bzero(p + st->size, (sz - st->size) * sizeof(wchar_t)); *st->pbuf = st->string = p; st->size = sz; } @@ -146,7 +145,6 @@ open_wmemstream(wchar_t **pbuf, size_t *psize) return (NULL); } - *st->string = L'\0'; st->pos = 0; st->len = 0; st->pbuf = pbuf;