diff options
author | Andrei Vagin <avagin@google.com> | 2021-06-07 14:08:28 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-06-07 14:11:30 -0700 |
commit | b3a44bfab826709fc618e5c14835c06539b054cf (patch) | |
tree | f11ef1965bb9f3c0e3913765ac8b8eee543f9fc4 /test/syscalls | |
parent | 7e4e71253ec7c06f2f4eaf387826f08a8b3373cb (diff) |
test: use std::vector instead of allocating memory with calloc
A memory that is allocated with calloc has to be freed.
PiperOrigin-RevId: 378001409
Diffstat (limited to 'test/syscalls')
-rw-r--r-- | test/syscalls/linux/udp_socket.cc | 4 |
1 files 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<char*>(calloc(1, control_buf_len)); + std::vector<char> 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<void*>(&remote); msg.msg_namelen = addrlen_; |