Skip to content

Commit

Permalink
Fix memory leak in tests
Browse files Browse the repository at this point in the history
test_tcp_server had a memory leak by not deleting manually allocated clients.
  • Loading branch information
fmauch committed Jun 28, 2023
1 parent 56efec5 commit 81a3157
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/test_tcp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <gtest/gtest.h>
#include <condition_variable>
#include <chrono>
#include <memory>

#include <ur_client_library/comm/tcp_server.h>
#include <ur_client_library/comm/tcp_socket.h>
Expand Down Expand Up @@ -225,13 +226,12 @@ TEST_F(TCPServerTest, unlimited_clients_allowed)
server.start();

// Test that a large number of clients can connect to the server
std::vector<Client*> clients;
Client* client;
std::vector<std::unique_ptr<Client>> clients;
std::unique_ptr<Client> client;
for (unsigned int i = 0; i < 100; ++i)
{
client = new Client(port_);
clients.push_back(std::make_unique<Client>(port_));
ASSERT_TRUE(waitForConnectionCallback());
clients.push_back(client);
}
}

Expand Down

0 comments on commit 81a3157

Please sign in to comment.