exactly this use case where the new memory needs to be zeroed during resize.
Since recallocarray() takes care of all this there is no need to bzero()
memory anymore.
OK tb@ millert@
-/* $OpenBSD: open_memstream.c,v 1.8 2019/05/02 08:30:10 yasuoka Exp $ */
+/* $OpenBSD: open_memstream.c,v 1.9 2023/06/21 13:11:49 claudio Exp $ */
/*
* Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
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;
}
-/* $OpenBSD: open_wmemstream.c,v 1.8 2015/09/12 16:23:14 guenther Exp $ */
+/* $OpenBSD: open_wmemstream.c,v 1.9 2023/06/21 13:11:49 claudio Exp $ */
/*
* Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
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;
}