Bug 1216815 - fix memory leaks in test TCP STUN server. r=mjf
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Tue, 20 Oct 2015 17:07:09 -0700
changeset 269166 e33fcdc71dd67b361e3d747ebf5a321a4af5f00d
parent 269165 ad80366135f31aa550911d7911ce6352dc5369d3
child 269167 8315a152ccb1cb77d57652daf7ce5ab688582ced
push id67027
push usercbook@mozilla.com
push dateFri, 23 Oct 2015 07:23:28 +0000
treeherdermozilla-inbound@8315a152ccb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjf
bugs1216815
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1216815 - fix memory leaks in test TCP STUN server. r=mjf
media/mtransport/test/stunserver.cpp
--- a/media/mtransport/test/stunserver.cpp
+++ b/media/mtransport/test/stunserver.cpp
@@ -603,28 +603,31 @@ void TestStunTcpServer::accept_cb(NR_SOC
   /* accept */
   if (nr_socket_accept(server->listen_sock_, &remote_addr, &newsock)) {
     MOZ_MTLOG(ML_ERROR, "Couldn't accept incoming tcp connection");
     return;
   }
 
   if(nr_socket_buffered_stun_create(newsock, 2048, TURN_TCP_FRAMING, &bufsock)) {
     MOZ_MTLOG(ML_ERROR, "Couldn't create connected tcp socket");
+    nr_socket_destroy(&newsock);
     return;
   }
 
   nr_socket_buffered_set_connected_to(bufsock, &remote_addr);
 
   if(nr_socket_wrapped_create(bufsock, &wrapsock)) {
     MOZ_MTLOG(ML_ERROR, "Couldn't wrap connected tcp socket");
+    nr_socket_destroy(&bufsock);
     return;
   }
 
-  if(nr_socket_getfd(bufsock, &fd)) {
+  if(nr_socket_getfd(wrapsock, &fd)) {
     MOZ_MTLOG(ML_ERROR, "Couldn't get fd from connected tcp socket");
+    nr_socket_destroy(&wrapsock);
     return;
   }
 
   server->connections_[fd] = wrapsock;
 
   NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server);
 }