Assert that the port numbers are set prior to being used

This commit is contained in:
Cameron Gutman
2021-07-02 01:44:11 -05:00
parent cdda221d64
commit 3b9d8a3176
6 changed files with 29 additions and 6 deletions

View File

@@ -1142,6 +1142,8 @@ int startControlStream(void) {
ENetAddress address;
ENetEvent event;
LC_ASSERT(ControlPortNumber != 0);
enet_address_set_address(&address, (struct sockaddr *)&RemoteAddr, RemoteAddrLen);
enet_address_set_port(&address, ControlPortNumber);
@@ -1183,6 +1185,7 @@ int startControlStream(void) {
}
else {
// NB: Do NOT use ControlPortNumber here. 47995 is correct for these old versions.
LC_ASSERT(ControlPortNumber == 0);
ctlSock = connectTcpSocket(&RemoteAddr, RemoteAddrLen,
47995, CONTROL_STREAM_TIMEOUT_SEC);
if (ctlSock == INVALID_SOCKET) {