Skip to content

Commit

Permalink
[?] Fix memory leak of startupPack in agents.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Nov 11, 2024
1 parent 4abb262 commit 9cdd5cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/main_server/src/agent_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,10 @@ namespace
}

net_obj->socket_handle(_socket_fd);

startupPack_t* startupPack = nullptr;
irods::at_scope_exit free_startupPack{[&startupPack] { std::free(startupPack); }};

struct timeval tv;
tv.tv_sec = READ_STARTUP_PACK_TOUT_SEC;
tv.tv_usec = 0;
Expand All @@ -751,7 +754,6 @@ namespace
log_agent::error("{}: Exceeded server-to-server connect count [count={}, max={}].", __func__, startupPack->connectCnt, max_svr_to_svr_connect_count);
sendVersion(net_obj, SYS_EXCEED_CONNECT_CNT, 0, nullptr, 0);
mySockClose(net_obj->socket_handle());
std::free(startupPack);
return 0;
}

Expand Down Expand Up @@ -780,15 +782,13 @@ namespace
}

mySockClose(net_obj->socket_handle());
std::free(startupPack);
return 0;
}

if (startupPack->clientUser[0] != '\0') {
if (const auto ec = chkAllowedUser(startupPack->clientUser, startupPack->clientRodsZone); ec < 0) {
sendVersion(net_obj, ec, 0, nullptr, 0);
mySockClose(net_obj->socket_handle());
std::free(startupPack);
return 0;
}
}
Expand Down

0 comments on commit 9cdd5cd

Please sign in to comment.