Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: webrtc/rtc_base/network_unittest.cc

Issue 2999053002: Fix a delete type mismatch (deleting a sockaddr_in6* as a sockaddr*) (Closed)
Patch Set: Rework to use malloc/free Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/rtc_base/network_unittest.cc
diff --git a/webrtc/rtc_base/network_unittest.cc b/webrtc/rtc_base/network_unittest.cc
index b5c5912aa867321ec44a5ddb43a97194c551356b..9af9294c6c396bae01ca31d5918ba978da85f79e 100644
--- a/webrtc/rtc_base/network_unittest.cc
+++ b/webrtc/rtc_base/network_unittest.cc
@@ -10,8 +10,11 @@
#include "webrtc/rtc_base/network.h"
+#include <stdlib.h>
+
#include <memory>
#include <vector>
+
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/nethelpers.h"
#include "webrtc/rtc_base/networkmonitor.h"
@@ -122,7 +125,8 @@ class NetworkTest : public testing::Test, public sigslot::has_slots<> {
struct sockaddr_in6* CreateIpv6Addr(const std::string& ip_string,
uint32_t scope_id) {
- struct sockaddr_in6* ipv6_addr = new struct sockaddr_in6;
+ struct sockaddr_in6* ipv6_addr = static_cast<struct sockaddr_in6*>(
+ malloc(sizeof(struct sockaddr_in6)));
kwiberg-webrtc 2017/08/17 22:18:48 Note: Unlike in C, in C++ you don't have to say "s
oprypin_webrtc 2017/08/18 07:12:37 Leaving as is because these pure C structs are ref
memset(ipv6_addr, 0, sizeof(struct sockaddr_in6));
kwiberg-webrtc 2017/08/17 22:18:48 You could replace the malloc+memset pair with call
oprypin_webrtc 2017/08/18 07:12:37 I did give `calloc` a fair consideration, but it's
ipv6_addr->sin6_family = AF_INET6;
ipv6_addr->sin6_scope_id = scope_id;
@@ -168,8 +172,8 @@ class NetworkTest : public testing::Test, public sigslot::has_slots<> {
struct ifaddrs* if_addr = list;
while (if_addr != nullptr) {
struct ifaddrs* next_addr = if_addr->ifa_next;
- delete if_addr->ifa_addr;
- delete if_addr->ifa_netmask;
+ free(if_addr->ifa_addr);
+ free(if_addr->ifa_netmask);
delete if_addr;
if_addr = next_addr;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698