On Tue, Jun 20, 2023 at 05:49:46PM +0200, Claudio Jeker wrote: > In open_memstream() the code does a bzero() of the new memory even though > recallocarray() used which does this already. > > In open_wmemstream() the code does the same but is still using > reallocarray(). So adjust that code to be like open_memstream().
ok > > -- > :wq Claudio > > Index: open_memstream.c > =================================================================== > RCS file: /cvs/src/lib/libc/stdio/open_memstream.c,v > retrieving revision 1.8 > diff -u -p -r1.8 open_memstream.c > --- open_memstream.c 2 May 2019 08:30:10 -0000 1.8 > +++ open_memstream.c 8 Jun 2023 12:21:50 -0000 > @@ -53,7 +53,6 @@ memstream_write(void *v, const char *b, > 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; > } > Index: open_wmemstream.c > =================================================================== > RCS file: /cvs/src/lib/libc/stdio/open_wmemstream.c,v > retrieving revision 1.8 > diff -u -p -r1.8 open_wmemstream.c > --- open_wmemstream.c 12 Sep 2015 16:23:14 -0000 1.8 > +++ open_wmemstream.c 15 Jun 2023 14:54:42 -0000 > @@ -52,10 +52,9 @@ wmemstream_write(void *v, const char *b, > > 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; > } >