From b3a44bfab826709fc618e5c14835c06539b054cf Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Mon, 7 Jun 2021 14:08:28 -0700 Subject: test: use std::vector instead of allocating memory with calloc A memory that is allocated with calloc has to be freed. PiperOrigin-RevId: 378001409 --- test/syscalls/linux/udp_socket.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/syscalls/linux/udp_socket.cc b/test/syscalls/linux/udp_socket.cc index 29e174f71..2b687c198 100644 --- a/test/syscalls/linux/udp_socket.cc +++ b/test/syscalls/linux/udp_socket.cc @@ -791,14 +791,14 @@ TEST_P(UdpSocketTest, RecvErrorConnRefused) { iov.iov_len = kBufLen; size_t control_buf_len = CMSG_SPACE(sizeof(sock_extended_err) + addrlen_); - char* control_buf = static_cast(calloc(1, control_buf_len)); + std::vector control_buf(control_buf_len); struct sockaddr_storage remote; memset(&remote, 0, sizeof(remote)); struct msghdr msg = {}; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_flags = 0; - msg.msg_control = control_buf; + msg.msg_control = control_buf.data(); msg.msg_controllen = control_buf_len; msg.msg_name = reinterpret_cast(&remote); msg.msg_namelen = addrlen_; -- cgit v1.2.3