Skip to content

Commit

Permalink
fix for handling memory on socket timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed Nov 15, 2024
1 parent 563e6c4 commit 6e70a07
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/wolfsshd/wolfsshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2468,9 +2468,11 @@ static int StartSSHD(int argc, char** argv)
struct sockaddr_in6 clientAddr;
socklen_t clientAddrSz = sizeof(clientAddr);
#endif
conn = (WOLFSSHD_CONNECTION*)WMALLOC(sizeof(WOLFSSHD_CONNECTION), NULL, DYNTYPE_SSHD);
conn = (WOLFSSHD_CONNECTION*)WMALLOC(sizeof(WOLFSSHD_CONNECTION),
NULL, DYNTYPE_SSHD);
if (conn == NULL) {
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Failed to malloc memory for connection");
wolfSSH_Log(WS_LOG_ERROR,
"[SSHD] Failed to malloc memory for connection");
break;
}

Expand Down Expand Up @@ -2536,9 +2538,13 @@ static int StartSSHD(int argc, char** argv)
}
ret = NewConnection(conn);
}
else {
XFREE(conn, NULL, DYNTYPE_SSHD);
}
#ifdef _WIN32
/* check if service has been shutdown */
if (isDaemon && WaitForSingleObject(serviceStop, 0) == WAIT_OBJECT_0) {
if (isDaemon && WaitForSingleObject(serviceStop, 0) ==
WAIT_OBJECT_0) {
quit = 1;
}
#endif
Expand Down

0 comments on commit 6e70a07

Please sign in to comment.