mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 09:24:47 +00:00
Merge pull request #6060
1554a7768
unit_tests: fix use after free (moneromooo-monero)
This commit is contained in:
commit
0183ab78bc
1 changed files with 16 additions and 7 deletions
|
@ -262,16 +262,25 @@ TEST(ban, ignores_port)
|
||||||
|
|
||||||
TEST(node_server, bind_same_p2p_port)
|
TEST(node_server, bind_same_p2p_port)
|
||||||
{
|
{
|
||||||
const auto new_node = []() -> std::unique_ptr<Server> {
|
struct test_data_t
|
||||||
|
{
|
||||||
test_core pr_core;
|
test_core pr_core;
|
||||||
cryptonote::t_cryptonote_protocol_handler<test_core> cprotocol(pr_core, NULL);
|
cryptonote::t_cryptonote_protocol_handler<test_core> cprotocol;
|
||||||
std::unique_ptr<Server> server(new Server(cprotocol));
|
std::unique_ptr<Server> server;
|
||||||
cprotocol.set_p2p_endpoint(server.get());
|
|
||||||
|
|
||||||
return server;
|
test_data_t(): cprotocol(pr_core, NULL)
|
||||||
|
{
|
||||||
|
server.reset(new Server(cprotocol));
|
||||||
|
cprotocol.set_p2p_endpoint(server.get());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto init = [](const std::unique_ptr<Server>& server, const char* port) -> bool {
|
const auto new_node = []() -> std::unique_ptr<test_data_t> {
|
||||||
|
test_data_t *d = new test_data_t;
|
||||||
|
return std::unique_ptr<test_data_t>(d);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto init = [](const std::unique_ptr<test_data_t>& server, const char* port) -> bool {
|
||||||
boost::program_options::options_description desc_options("Command line options");
|
boost::program_options::options_description desc_options("Command line options");
|
||||||
cryptonote::core::init_options(desc_options);
|
cryptonote::core::init_options(desc_options);
|
||||||
Server::init_options(desc_options);
|
Server::init_options(desc_options);
|
||||||
|
@ -284,7 +293,7 @@ TEST(node_server, bind_same_p2p_port)
|
||||||
|
|
||||||
boost::program_options::notify(vm);
|
boost::program_options::notify(vm);
|
||||||
|
|
||||||
return server->init(vm);
|
return server->server->init(vm);
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr char port[] = "48080";
|
constexpr char port[] = "48080";
|
||||||
|
|
Loading…
Reference in a new issue