Use mallocarray(9) in CloudABI kernel code where possible.

Submitted by:	pfg@
This commit is contained in:
Ed Schouten 2018-01-07 22:38:45 +00:00
parent 565a0a2c65
commit 4b6b56b32b
2 changed files with 4 additions and 4 deletions

View File

@ -60,7 +60,7 @@ cloudabi32_sys_sock_recv(struct thread *td,
/* Convert iovecs to native format. */
if (ri.ri_data_len > UIO_MAXIOV)
return (EINVAL);
iov = malloc(ri.ri_data_len * sizeof(struct iovec),
iov = mallocarray(ri.ri_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(ri.ri_data);
for (i = 0; i < ri.ri_data_len; i++) {
@ -104,7 +104,7 @@ cloudabi32_sys_sock_send(struct thread *td,
/* Convert iovecs to native format. */
if (si.si_data_len > UIO_MAXIOV)
return (EINVAL);
iov = malloc(si.si_data_len * sizeof(struct iovec),
iov = mallocarray(si.si_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(si.si_data);
for (i = 0; i < si.si_data_len; i++) {

View File

@ -60,7 +60,7 @@ cloudabi64_sys_sock_recv(struct thread *td,
/* Convert iovecs to native format. */
if (ri.ri_data_len > UIO_MAXIOV)
return (EINVAL);
iov = malloc(ri.ri_data_len * sizeof(struct iovec),
iov = mallocarray(ri.ri_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(ri.ri_data);
for (i = 0; i < ri.ri_data_len; i++) {
@ -104,7 +104,7 @@ cloudabi64_sys_sock_send(struct thread *td,
/* Convert iovecs to native format. */
if (si.si_data_len > UIO_MAXIOV)
return (EINVAL);
iov = malloc(si.si_data_len * sizeof(struct iovec),
iov = mallocarray(si.si_data_len, sizeof(struct iovec),
M_SOCKET, M_WAITOK);
user_iov = TO_PTR(si.si_data);
for (i = 0; i < si.si_data_len; i++) {