From 4d65e9320ab33a5a1291ab4c3c2fedae6f4bb80d Mon Sep 17 00:00:00 2001 From: "ericroman@google.com" Date: Sat, 18 Jul 2009 08:50:37 +0000 Subject: Use new char[] to match the delete[]. To fix a valgrind error. BUG=http://crbug.com/17169 TBR=willchan TEST=SOCKS5 unit test under valgrind. Review URL: http://codereview.chromium.org/159052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21055 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/address_list.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'net') diff --git a/net/base/address_list.cc b/net/base/address_list.cc index 7cfab3f..7a18f04 100644 --- a/net/base/address_list.cc +++ b/net/base/address_list.cc @@ -134,12 +134,13 @@ AddressList AddressList::CreateIPv6Address(unsigned char data[16]) { ai->ai_family = AF_INET6; ai->ai_socktype = SOCK_STREAM; - ai->ai_addrlen = sizeof(sockaddr_in6); + ai->ai_addrlen = sizeof(struct sockaddr_in6); - struct sockaddr_in6* addr6 = new sockaddr_in6; - memset(addr6, 0, sizeof(sockaddr_in6)); + struct sockaddr_in6* addr6 = reinterpret_cast( + new char[ai->ai_addrlen]); + memset(addr6, 0, sizeof(struct sockaddr_in6)); - ai->ai_addr = reinterpret_cast(addr6); + ai->ai_addr = reinterpret_cast(addr6); addr6->sin6_family = AF_INET6; memcpy(&addr6->sin6_addr, data, 16); -- cgit v1.1