diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 14:57:49 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 14:57:49 +0000 |
commit | 23ce3973a2bead57dde8c741d1c2e90e15d1cf43 (patch) | |
tree | 318accad5e912159c20031f7603c438191ca7a5f /net/base/address_list.cc | |
parent | c398f7ee9485e90cb163c7e59beab21117c71f4a (diff) | |
download | chromium_src-23ce3973a2bead57dde8c741d1c2e90e15d1cf43.zip chromium_src-23ce3973a2bead57dde8c741d1c2e90e15d1cf43.tar.gz chromium_src-23ce3973a2bead57dde8c741d1c2e90e15d1cf43.tar.bz2 |
Adding extra argument DCHECKs to AddressList methods.
BUG=40796
TEST=net_unittests.exe --gtest_filter="*AddressList*"
Review URL: http://codereview.chromium.org/1560028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/address_list.cc')
-rw-r--r-- | net/base/address_list.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/net/base/address_list.cc b/net/base/address_list.cc index 89c9496..cf7f0d5 100644 --- a/net/base/address_list.cc +++ b/net/base/address_list.cc @@ -19,6 +19,7 @@ namespace { // DeleteCopyOfAddrinfo(), and NOT freeaddrinfo(). struct addrinfo* CreateCopyOfAddrinfo(const struct addrinfo* info, bool recursive) { + DCHECK(info); struct addrinfo* copy = new addrinfo; // Copy all the fields (some of these are pointers, we will fix that next). @@ -50,6 +51,7 @@ struct addrinfo* CreateCopyOfAddrinfo(const struct addrinfo* info, // Free an addrinfo that was created by CreateCopyOfAddrinfo(). void FreeMyAddrinfo(struct addrinfo* info) { + DCHECK(info); if (info->ai_canonname) free(info->ai_canonname); // Allocated by strdup. @@ -67,6 +69,7 @@ void FreeMyAddrinfo(struct addrinfo* info) { // Returns the address to port field in |info|. uint16* GetPortField(const struct addrinfo* info) { + DCHECK(info); if (info->ai_family == AF_INET) { DCHECK_EQ(sizeof(sockaddr_in), info->ai_addrlen); struct sockaddr_in* sockaddr = @@ -106,6 +109,7 @@ void AddressList::Copy(const struct addrinfo* head, bool recursive) { } void AddressList::Append(const struct addrinfo* head) { + DCHECK(head); struct addrinfo* new_head; if (data_->is_system_created) { new_head = CreateCopyOfAddrinfo(data_->head, true); @@ -118,6 +122,7 @@ void AddressList::Append(const struct addrinfo* head) { struct addrinfo* copy_ptr = new_head; while (copy_ptr->ai_next) copy_ptr = copy_ptr->ai_next; + DCHECK(!head->ai_canonname); copy_ptr->ai_next = CreateCopyOfAddrinfo(head, true); } @@ -176,6 +181,11 @@ AddressList AddressList::CreateIPv6Address(unsigned char data[16]) { return AddressList(new Data(ai, false /*is_system_created*/)); } +AddressList::Data::Data(struct addrinfo* ai, bool is_system_created) + : head(ai), is_system_created(is_system_created) { + DCHECK(head); +} + AddressList::Data::~Data() { // Call either freeaddrinfo(head), or FreeMyAddrinfo(head), depending who // created the data. |